/* ── SpeedFerret Site CSS ─────────────────────────────────────────────────── */

:root {
  --bg:        #0f1117;
  --bg2:       #191c26;
  --bg3:       #23273a;
  --border:    #2e3347;
  --text:      #eef0f6;
  --text2:     #8b92aa;
  --accent:    #D85A30;
  --accent2:   #f0824a;
  --green:     #4caf6e;
  --red:       #e24b4a;
  --gold:      #f5c842;
  --radius:    12px;
  --radius-sm: 6px;
  --font-head: 'Fredoka', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --header-h:  64px;
  --sidebar-w: 160px;
}

[data-theme="light"] {
  --bg:     #f5f3ef;
  --bg2:    #ffffff;
  --bg3:    #ede9e2;
  --border: #d8d2c8;
  --text:   #1a1612;
  --text2:  #6b6358;
  --bg3:    #e8e2d8;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.sf-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.sf-logo-link {
  display: flex; align-items: center; gap: .6rem;
  text-decoration: none; flex-shrink: 0;
}

.sf-ferret-logo { width: 42px; height: 42px; flex-shrink: 0; }

.sf-logo-text {
  font-family: var(--font-head);
  font-size: 1.5rem; font-weight: 600;
  color: var(--text); letter-spacing: -.3px;
}
.sf-logo-text em { color: var(--accent); font-style: normal; }

.sf-nav {
  display: flex; gap: .5rem; align-items: center; margin-left: auto;
}
.sf-nav a {
  color: var(--text2); text-decoration: none;
  font-size: .875rem; padding: .4rem .75rem;
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
}
.sf-nav a:hover { background: var(--bg3); color: var(--text); }
.sf-nav-profile { font-family: monospace; font-size: .8rem !important; }

.sf-theme-toggle {
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .3rem .5rem;
  cursor: pointer; font-size: 1rem; color: var(--text2);
  transition: border-color .15s;
  flex-shrink: 0;
}
.sf-theme-toggle:hover { border-color: var(--text2); }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.sf-ad-top {
  min-height: 90px; display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--border); background: var(--bg2);
}

.sf-layout {
  display: flex; flex: 1; gap: 0;
  max-width: 1400px; margin: 0 auto; width: 100%;
  padding: 1.5rem 1rem;
}

.sf-main {
  flex: 1; min-width: 0;
  padding: 0 1rem;
}

.sf-ad-sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  display: none;
}

.sf-ad {
  background: var(--bg2); border: 1px dashed var(--border);
  border-radius: var(--radius);
  min-height: 250px; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: .5rem;
  position: sticky; top: calc(var(--header-h) + 1rem);
}

.sf-ad-label {
  font-size: .7rem; color: var(--text2); text-transform: uppercase;
  letter-spacing: .05em;
}

.sf-ad-sticky {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: var(--bg2); border-top: 1px solid var(--border);
  min-height: 60px; align-items: center; justify-content: center;
  padding: .5rem 3rem .5rem 1rem;
}
.sf-ad-close {
  position: absolute; right: .75rem;
  background: none; border: none; color: var(--text2);
  font-size: 1rem; cursor: pointer;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.sf-footer {
  display: flex; gap: 1.5rem; align-items: center; justify-content: center;
  padding: 1rem; font-size: .8rem; color: var(--text2);
  border-top: 1px solid var(--border);
}
.sf-footer a { color: var(--text2); text-decoration: none; }
.sf-footer a:hover { color: var(--text); }

/* ── Typography helpers ───────────────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; line-height: 1.2; }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.sf-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  transition: border-color .15s, transform .15s;
}
.sf-card:hover { border-color: var(--accent); transform: translateY(-2px); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.sf-btn {
  font-family: var(--font-head); font-weight: 500;
  padding: .65rem 1.5rem; border-radius: var(--radius-sm);
  border: none; cursor: pointer; font-size: 1rem;
  display: inline-flex; align-items: center; gap: .4rem;
  transition: opacity .15s, transform .1s;
}
.sf-btn:hover { opacity: .9; transform: translateY(-1px); }
.sf-btn:active { transform: translateY(0); }
.sf-btn-primary { background: var(--accent); color: #fff; }
.sf-btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.sf-btn-lg { font-size: 1.2rem; padding: .9rem 2rem; }

/* ── Badge ───────────────────────────────────────────────────────────────── */
.sf-badge {
  display: inline-block; font-size: .7rem; font-weight: 500;
  padding: .2rem .6rem; border-radius: 999px;
  letter-spacing: .03em; text-transform: uppercase;
}
.sf-badge-orange { background: #3a2010; color: var(--accent2); }
.sf-badge-green  { background: #0e2a18; color: var(--green); }

/* ── HUD row ──────────────────────────────────────────────────────────────── */
.sf-hud {
  display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.sf-hud-box {
  background: var(--bg3); border-radius: var(--radius-sm);
  padding: .5rem .9rem; text-align: center; min-width: 60px;
}
.sf-hud-label { font-size: .65rem; color: var(--text2); text-transform: lowercase; }
.sf-hud-val   { font-size: 1.3rem; font-weight: 500; color: var(--text); font-family: var(--font-head); }

/* ── Leaderboard table ───────────────────────────────────────────────────── */
.sf-table { width: 100%; border-collapse: collapse; }
.sf-table th {
  text-align: left; font-size: .75rem; color: var(--text2);
  text-transform: uppercase; letter-spacing: .04em;
  padding: .5rem .75rem; border-bottom: 1px solid var(--border);
}
.sf-table td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
.sf-table tr:last-child td { border-bottom: none; }
.sf-table tr:hover td { background: var(--bg3); }
.sf-rank { font-family: var(--font-head); font-size: 1rem; color: var(--text2); }
.sf-rank-1 { color: var(--gold); }
.sf-rank-2 { color: #cdd; }
.sf-rank-3 { color: #c9804a; }
.sf-uid-link { font-family: monospace; font-size: .85rem; color: var(--accent); text-decoration: none; }
.sf-uid-link:hover { text-decoration: underline; }

/* ── Game grid (home) ────────────────────────────────────────────────────── */
.sf-game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem; margin-top: 1.5rem;
}
.sf-game-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem 1.25rem;
  text-decoration: none; color: var(--text);
  display: block; transition: border-color .15s, transform .15s;
}
.sf-game-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.sf-game-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.sf-game-title { font-family: var(--font-head); font-size: 1.2rem; margin-bottom: .4rem; }
.sf-game-desc  { font-size: .85rem; color: var(--text2); line-height: 1.5; }

/* ── Username / nickname section ─────────────────────────────────────────── */
.sf-uid-display {
  display: inline-block; font-family: monospace; font-size: 1rem;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .4rem 1rem;
  letter-spacing: .05em; color: var(--accent);
}

.sf-nick-form { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.sf-nick-input {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .5rem .9rem;
  color: var(--text); font-family: var(--font-body); font-size: .95rem;
  width: 220px;
}
.sf-nick-input:focus { outline: none; border-color: var(--accent); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (min-width: 900px) {
  .sf-ad-sidebar { display: block; }
}

@media (max-width: 600px) {
  .sf-ad-top { display: none; }
  .sf-ad-sticky { display: flex; }
  .sf-layout { padding: 1rem .5rem; }
  .sf-main { padding: 0; }
  h1 { font-size: 1.5rem; }
  .sf-logo-text { font-size: 1.2rem; }
}

@media (min-width: 601px) {
  .sf-ad-sticky { display: none !important; }
}

/* ── Instruction / welcome page ──────────────────────────────────────────── */
.sf-welcome { max-width: 640px; }
.sf-welcome-hero {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 2rem 0 1.5rem;
}
.sf-welcome-hero .sf-ferret-logo { width: 80px; height: 80px; }
.sf-welcome p { color: var(--text2); line-height: 1.7; margin: .75rem 0; }

.sf-game-instructions { margin: 1.5rem 0; }
.sf-game-instructions h3 { color: var(--accent); margin-bottom: .5rem; }
.sf-game-instructions ul { padding-left: 1.2rem; color: var(--text2); line-height: 1.8; }

/* ── Profile page ────────────────────────────────────────────────────────── */
.sf-profile-header {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.sf-profile-stats {
  display: flex; gap: 1rem; flex-wrap: wrap; margin: 1rem 0 1.5rem;
}
.sf-profile-stat {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.5rem; text-align: center;
}
.sf-profile-stat-val { font-family: var(--font-head); font-size: 2rem; color: var(--accent); }
.sf-profile-stat-lbl { font-size: .8rem; color: var(--text2); }

/* ── Notification toast ──────────────────────────────────────────────────── */
#sf-toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .6rem 1.2rem;
  font-size: .9rem; opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none; z-index: 300; white-space: nowrap;
}
#sf-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Ad slot sizing — responsive, collapses with viewport ────────────────── */
.sf-ad-top {
  /* Override: constrain to standard banner sizes, never taller than 90px */
  min-height: 0 !important;
  height: 90px;
  padding: 0;
  overflow: hidden;
}

/* Inner ad unit wrapper — centres and caps width at 728px (leaderboard) */
.sf-ad-top-inner {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  max-width: 728px; margin: 0 auto;
}

/* Responsive banner breakpoints:
   ≥728px  → 728×90  full leaderboard
   ≥468px  → 468×60  half banner
   <468px  → hide entirely (mobile sticky footer takes over)          */
@media (max-width: 727px) {
  .sf-ad-top { height: 60px; }
}
@media (max-width: 467px) {
  .sf-ad-top { display: none !important; }
}

/* ── Mobile header fixes — prevent content getting cut off ───────────────── */
@media (max-width: 420px) {
  :root { --header-h: auto; }

  .sf-header {
    height: auto;
    flex-wrap: wrap;
    padding: .5rem .75rem;
    gap: .4rem;
    row-gap: .4rem;
  }

  /* Logo stays on left, theme toggle on right of same row */
  .sf-logo-link { flex: 1; }
  .sf-ferret-logo { width: 32px; height: 32px; }
  .sf-logo-text { font-size: 1.1rem; }

  /* Nav wraps onto its own full-width row */
  .sf-nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    gap: .25rem;
    flex-wrap: wrap;
  }
  .sf-nav a {
    font-size: .75rem;
    padding: .3rem .5rem;
  }
  .sf-nav-profile {
    font-size: .7rem !important;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sf-theme-toggle {
    order: 2;
    padding: .25rem .4rem;
    font-size: .9rem;
  }
}

/* ── Legal pages (Terms & Privacy) ──────────────────────────────────────── */
.sf-legal {
  max-width: 780px;
  line-height: 1.75;
}

.sf-legal-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.sf-legal-header h1 {
  font-size: 2rem;
  margin-bottom: .4rem;
}

.sf-legal-meta {
  font-size: .85rem;
  color: var(--text2);
  margin-bottom: 1rem;
}

.sf-legal-intro {
  font-size: 1.05rem;
  color: var(--text2);
  max-width: 640px;
}

/* Table of contents */
.sf-legal-toc {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem 1rem 1.5rem;
  margin-bottom: 2rem;
  display: inline-block;
  min-width: 260px;
}

.sf-legal-toc strong {
  display: block;
  margin-bottom: .5rem;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text2);
}

.sf-legal-toc ol {
  padding-left: 1.2rem;
  margin: 0;
}

.sf-legal-toc li {
  margin: .3rem 0;
  font-size: .9rem;
}

.sf-legal-toc a {
  color: var(--accent);
  text-decoration: none;
}

.sf-legal-toc a:hover {
  text-decoration: underline;
}

/* Sections */
.sf-legal-section {
  margin-bottom: 2.25rem;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.sf-legal-section h2 {
  font-size: 1.25rem;
  color: var(--text);
  margin-bottom: .75rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
}

.sf-legal-section h3 {
  font-size: 1rem;
  color: var(--text);
  margin: 1rem 0 .4rem;
}

.sf-legal-section p {
  color: var(--text2);
  margin-bottom: .75rem;
}

.sf-legal-section ul,
.sf-legal-section ol {
  padding-left: 1.4rem;
  color: var(--text2);
  margin-bottom: .75rem;
}

.sf-legal-section li {
  margin: .35rem 0;
}

.sf-legal-section a {
  color: var(--accent);
  text-decoration: none;
}

.sf-legal-section a:hover {
  text-decoration: underline;
}

.sf-legal-section code {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .1rem .4rem;
  font-size: .88em;
  color: var(--text);
}

.sf-legal-section strong {
  color: var(--text);
}

/* Footer nav within legal pages */
.sf-legal-footer {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: .9rem;
  color: var(--text2);
}

.sf-legal-footer a {
  color: var(--accent);
  text-decoration: none;
}

.sf-legal-footer a:hover {
  text-decoration: underline;
}

/* Mobile legal */
@media (max-width: 600px) {
  .sf-legal-header h1 { font-size: 1.5rem; }
  .sf-legal-toc { display: block; }
  .sf-legal-section h2 { font-size: 1.1rem; }
}

/* ── Auth nav items ───────────────────────────────────────────────────────── */
.sf-nav-logout {
  color: var(--text2) !important;
  font-size: .78rem !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .3rem .65rem !important;
  transition: border-color .15s, color .15s;
}
.sf-nav-logout:hover {
  border-color: var(--red);
  color: var(--red) !important;
  background: none !important;
}
.sf-nav-login {
  color: var(--accent) !important;
  font-size: .82rem !important;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: .3rem .65rem !important;
}
.sf-nav-login:hover {
  background: var(--accent) !important;
  color: #fff !important;
}
