/* Tower Defense Hub — core site styles (mobile-first).
   Colour tokens are defined for light and dark themes; the theme is chosen by
   the visitor (light / dark / system) and applied via [data-theme] on <html>. */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eceff6;
  --surface-3: #e1e6f0;
  --text: #131a2a;
  --muted: #4f5b73;
  --border: #d5dbe8;
  --primary: #0b7285;
  --primary-hover: #095c6b;
  --primary-soft: #d8f1f4;
  --on-primary: #ffffff;
  --accent: #b36b00;
  --accent-soft: #fff1d6;
  --danger: #b3261e;
  --success: #1e7b34;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 1180px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-display: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --hero-from: #0b3d4a;
  --hero-to: #11244a;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020;
    --surface: #121a2e;
    --surface-2: #19233b;
    --surface-3: #212d48;
    --text: #e7ecf6;
    --muted: #a2afc8;
    --border: #28344f;
    --primary: #4fd1e0;
    --primary-hover: #7fe1ec;
    --primary-soft: #11343d;
    --on-primary: #06202a;
    --accent: #ffc247;
    --accent-soft: #3a2c0c;
    --danger: #ff8a80;
    --success: #7ddc92;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .45);
    --hero-from: #07202a;
    --hero-to: #0b1530;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1020;
  --surface: #121a2e;
  --surface-2: #19233b;
  --surface-3: #212d48;
  --text: #e7ecf6;
  --muted: #a2afc8;
  --border: #28344f;
  --primary: #4fd1e0;
  --primary-hover: #7fe1ec;
  --primary-soft: #11343d;
  --on-primary: #06202a;
  --accent: #ffc247;
  --accent-soft: #3a2c0c;
  --danger: #ff8a80;
  --success: #7ddc92;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .45);
  --hero-from: #07202a;
  --hero-to: #0b1530;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  overflow-x: hidden;
}
img, svg, canvas { max-width: 100%; }
img { height: auto; display: block; }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; letter-spacing: -.01em; margin: 0 0 .6em; }
h1 { font-size: clamp(1.9rem, 5.2vw, 3rem); font-weight: 800; }
h2 { font-size: clamp(1.4rem, 3.4vw, 1.9rem); font-weight: 750; margin-top: 1.6em; }
h3 { font-size: 1.2rem; font-weight: 700; margin-top: 1.3em; }
p { margin: 0 0 1em; }
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78em; padding: .1em .45em; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; color: var(--text);
}
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 780px; }

/* ---------------- Header ---------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) { .site-header { background: var(--surface); } }
.header-inner { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 1.12rem; letter-spacing: -.02em; flex-shrink: 0; }
.brand:hover { color: var(--text); }
.brand svg { width: 36px; height: 36px; flex-shrink: 0; }
.brand small { display: block; font-size: .68rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.brand-text { line-height: 1.15; }

.main-nav { margin-left: auto; }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; }
.nav-list a {
  display: block; white-space: nowrap; padding: 10px 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 600; font-size: .95rem;
}
.nav-list a:hover, .nav-list a[aria-current="page"] { background: var(--surface-2); color: var(--primary); }
.header-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; min-height: 44px; padding: 0 10px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-size: .9rem; font-weight: 600;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }
.nav-toggle { display: none; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 20px; border-radius: 12px;
  font: inherit; font-weight: 700; font-size: 1rem; text-decoration: none; cursor: pointer;
  border: 2px solid transparent; transition: background-color .15s, color .15s, border-color .15s, transform .15s;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-light { background: #fff; color: #0b2a3a; }
.btn-light:hover { background: #e6f7fa; color: #0b2a3a; }
.btn-ghost-light { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .55); }
.btn-ghost-light:hover { border-color: #fff; color: #fff; background: rgba(255, 255, 255, .08); }
.btn-sm { min-height: 40px; padding: 6px 14px; font-size: .92rem; }
.btn svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ---------------- Breadcrumbs ---------------- */
.breadcrumbs { font-size: .9rem; color: var(--muted); padding: 16px 0 4px; }
.breadcrumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.breadcrumbs li { display: inline-flex; align-items: center; gap: 4px; }
.breadcrumbs li + li::before { content: "›"; color: var(--muted); margin-right: 2px; }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--primary); text-decoration: underline; }

/* ---------------- Hero ---------------- */
.hero {
  position: relative; overflow: hidden; color: #fff;
  background: radial-gradient(1200px 500px at 85% -10%, rgba(79, 209, 224, .28), transparent 60%), linear-gradient(135deg, var(--hero-from), var(--hero-to));
  padding: 56px 0 64px;
}
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .18;
  background-image: linear-gradient(rgba(255, 255, 255, .25) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .25) 1px, transparent 1px);
  background-size: 40px 40px; mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .9), transparent 85%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .9), transparent 85%);
}
.hero .container { position: relative; z-index: 1; display: grid; gap: 32px; align-items: center; }
.hero h1 { color: #fff; margin-bottom: .3em; }
.hero .eyebrow { color: #ffd166; }
.hero-lead { font-size: clamp(1.05rem, 2.4vw, 1.3rem); color: #d7e7f3; max-width: 38em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.hero-art { max-width: 480px; justify-self: center; width: 100%; }
.hero-art svg { width: 100%; height: auto; filter: drop-shadow(0 20px 40px rgba(0, 0, 0, .35)); }
.eyebrow { display: inline-block; font-size: .8rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: .6em; }

.page-hero { padding: 8px 0 8px; }
.page-hero .lead { font-size: 1.15rem; color: var(--muted); max-width: 46em; }

/* ---------------- Sections ---------------- */
.section { padding: 44px 0; }
.section-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.section-head h2 { margin: 0; }
.section-head p { margin: 6px 0 0; color: var(--muted); max-width: 44em; }
.section-link { font-weight: 700; text-decoration: none; }
.section-link:hover { text-decoration: underline; }

/* ---------------- Grids & cards ---------------- */
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.grid-guides { grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); }
.grid-cats { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; position: relative;
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.game-card .thumb { aspect-ratio: 16 / 10; background: var(--surface-2); display: block; overflow: hidden; }
.game-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title { font-size: 1.12rem; margin: 0; }
.card-title a { color: var(--text); text-decoration: none; }
.card-title a::after { content: ""; position: absolute; inset: 0; z-index: 0; }
.card-title a:hover { color: var(--primary); }
.card-text { color: var(--muted); font-size: .95rem; margin: 0; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 4px; }
.card-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; position: relative; z-index: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 700; line-height: 1;
  padding: 6px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.chip-easy { color: var(--success); }
.chip-medium { color: var(--accent); }
.chip-hard { color: var(--danger); }
.fav-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer;
}
.fav-btn svg { width: 22px; height: 22px; }
.fav-btn[aria-pressed="true"] { color: #e5484d; border-color: #e5484d; background: color-mix(in srgb, #e5484d 10%, var(--surface)); }
.fav-btn:hover { border-color: #e5484d; color: #e5484d; }

.cat-card { padding: 18px; gap: 8px; }
.cat-card .cat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.cat-card .cat-icon svg { width: 26px; height: 26px; }
.cat-card h3 { margin: 6px 0 0; font-size: 1.1rem; }
.cat-card h3 a { color: var(--text); text-decoration: none; }
.cat-card h3 a::after { content: ""; position: absolute; inset: 0; }
.cat-card p { color: var(--muted); font-size: .94rem; margin: 0; }
.cat-count { font-size: .82rem; font-weight: 700; color: var(--primary); }

.guide-card { padding: 18px; gap: 8px; }
.guide-card h3 { margin: 0; font-size: 1.1rem; }
.guide-card h3 a { color: var(--text); text-decoration: none; }
.guide-card h3 a::after { content: ""; position: absolute; inset: 0; }
.guide-card p { color: var(--muted); font-size: .95rem; margin: 0; }
.guide-meta { font-size: .82rem; color: var(--muted); font-weight: 600; }

/* ---------------- Daily challenge panel ---------------- */
.daily-panel {
  display: grid; gap: 20px; align-items: center; padding: 24px; border-radius: 20px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 16%, var(--surface)), var(--surface));
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.daily-panel h2 { margin-top: 0; }
.daily-rules { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; }
.daily-rules li { padding-left: 26px; position: relative; }
.daily-rules li::before { content: ""; position: absolute; left: 4px; top: .6em; width: 10px; height: 10px; border-radius: 3px; background: var(--primary); transform: rotate(45deg); }
.daily-status { font-weight: 700; color: var(--success); }

/* ---------------- Prose ---------------- */
.prose { max-width: 760px; }
.prose > *:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1.1em; }
.prose li { margin-bottom: .35em; }
.prose blockquote { margin: 1.4em 0; padding: 12px 18px; border-left: 4px solid var(--primary); background: var(--surface-2); border-radius: 0 10px 10px 0; }
.prose pre { background: var(--surface-2); border: 1px solid var(--border); padding: 14px; border-radius: 10px; overflow-x: auto; font-size: .9rem; }
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.callout { margin: 1.4em 0; padding: 14px 18px; border-radius: 12px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.callout p:last-child { margin: 0; }
.table-wrap { overflow-x: auto; margin: 0 0 1.4em; border: 1px solid var(--border); border-radius: 12px; }
.data-table { width: 100%; border-collapse: collapse; font-size: .95rem; min-width: 460px; }
.data-table th, .data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table thead th { background: var(--surface-2); font-weight: 700; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.page-updated { color: var(--muted); font-size: .92rem; }

.article-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: .92rem; margin: 0 0 22px; }
.article-layout { display: grid; gap: 36px; }
.toc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; font-size: .95rem; }
.toc h2 { font-size: 1rem; margin: 0 0 8px; }
.toc ol { margin: 0; padding-left: 1.2em; }
.toc li { margin: 4px 0; }
.aside-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; }
.aside-box h2 { font-size: 1.05rem; margin: 0 0 10px; }
.aside-box ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.aside-box a { font-weight: 600; text-decoration: none; }
.aside-box a:hover { text-decoration: underline; }

/* ---------------- FAQ ---------------- */
.faq { display: grid; gap: 10px; max-width: 820px; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0 16px; }
.faq summary { cursor: pointer; font-weight: 700; padding: 14px 0; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.3rem; line-height: 1; color: var(--primary); }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 0 0 14px; color: var(--muted); }

/* ---------------- Search & filters ---------------- */
.search-box { position: relative; max-width: 560px; }
.search-box input {
  width: 100%; min-height: 50px; padding: 12px 16px 12px 46px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}
.search-box svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); pointer-events: none; }
.filters { display: grid; gap: 12px; margin: 20px 0 8px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.field { display: grid; gap: 4px; font-size: .88rem; font-weight: 700; color: var(--muted); min-width: 150px; flex: 1 1 150px; }
.field select, .field input, .field textarea {
  font: inherit; font-weight: 500; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; min-height: 46px; padding: 8px 12px; width: 100%;
}
.field textarea { min-height: 150px; resize: vertical; }
.results-count { color: var(--muted); font-size: .95rem; margin: 10px 0 16px; }
.empty-state { text-align: center; padding: 40px 16px; border: 2px dashed var(--border); border-radius: var(--radius); color: var(--muted); }
.empty-state strong { display: block; color: var(--text); font-size: 1.1rem; margin-bottom: 6px; }

.site-search-panel {
  position: fixed; inset: 0; z-index: 90; background: rgba(5, 10, 20, .55); display: none; padding: 70px 16px 16px;
}
.site-search-panel.open { display: block; }
.site-search-inner { max-width: 640px; margin: 0 auto; background: var(--surface); border-radius: 18px; padding: 18px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); max-height: calc(100vh - 100px); overflow: auto; }
.site-search-inner .search-box { max-width: none; }
.search-results { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.search-results a { display: block; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--text); background: var(--surface-2); }
.search-results a:hover, .search-results a:focus { background: var(--primary-soft); }
.search-results .sr-type { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--primary); display: block; }
.search-results small { color: var(--muted); display: block; }

/* ---------------- Ads (AdSense-ready, hidden until configured) ---------------- */
.ad-slot { margin: 28px auto; text-align: center; max-width: 100%; clear: both; }
.ad-slot[hidden] { display: none !important; }
.ad-slot::before { content: "Advertisement"; display: block; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.ad-slot ins { display: block; min-height: 100px; }

/* ---------------- Forms ---------------- */
.form { display: grid; gap: 14px; max-width: 640px; }
.form-note { font-size: .92rem; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
.form-status { font-weight: 700; }
.form-status.error { color: var(--danger); }
.form-status.ok { color: var(--success); }

/* ---------------- Footer ---------------- */
.site-footer { margin-top: 56px; background: var(--surface); border-top: 1px solid var(--border); padding: 40px 0 28px; font-size: .95rem; }
.footer-grid { display: grid; gap: 28px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
.footer-grid h2 { font-size: .95rem; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 10px; color: var(--muted); }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.footer-grid a { color: var(--text); text-decoration: none; }
.footer-grid a:hover { color: var(--primary); text-decoration: underline; }
.footer-bottom { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 10px 20px; justify-content: space-between; color: var(--muted); font-size: .88rem; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------------- Consent banner ---------------- */
.consent {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 80; max-width: 720px; margin: 0 auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 16px 18px; display: grid; gap: 12px;
}
.consent[hidden] { display: none; }
.consent p { margin: 0; font-size: .95rem; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------------- Misc ---------------- */
.notice { padding: 12px 16px; border-radius: 12px; background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); }
.two-col { display: grid; gap: 28px; }
.steps { counter-reset: s; list-style: none; padding: 0; display: grid; gap: 12px; }
.steps li { counter-increment: s; position: relative; padding: 14px 16px 14px 58px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.steps li::before { content: counter(s); position: absolute; left: 14px; top: 12px; width: 32px; height: 32px; border-radius: 10px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 800; }
.feature-list { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); list-style: none; padding: 0; margin: 0; }
.feature-list li { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.feature-list strong { display: block; margin-bottom: 4px; }
.notfound { text-align: center; padding: 40px 0; }
.notfound svg { width: min(320px, 80%); height: auto; margin: 0 auto 10px; display: block; }
.link-list { display: flex; flex-wrap: wrap; gap: 10px; list-style: none; padding: 0; margin: 0; }
.sitemap-list { columns: 2 240px; column-gap: 32px; }
.sitemap-list li { break-inside: avoid; }
