:root {
  --paper: #FBF6EC;
  --paper-alt: #F4EDDA;
  --ink: #201F1D;
  --ink-soft: #5B5750;
  --accent: #E8484B;
  --accent-2: #3E92CC;
  --line: #E6DDC6;
  --card-bg: #FFFEFA;
  --radius: 18px;
  --radius-sm: 12px;
  --wobble: 255px 15px 225px 15px / 15px 225px 15px 255px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}
h1, h2, h3 {
  font-family: "Baloo 2", system-ui, sans-serif;
  font-weight: 800;
  line-height: 1.15;
  margin: 0 0 0.5em;
}
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); }
p { margin: 0 0 1em; color: var(--ink-soft); }
a { color: var(--accent-2); }
img { max-width: 100%; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff;
  padding: 10px 16px; z-index: 100; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* -- Header -- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(251, 246, 236, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 3px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 1.2rem; padding: 12px 20px; flex-wrap: wrap; }
.logo {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 1.3rem;
  color: var(--ink); text-decoration: none; flex-shrink: 0;
}
.logo em { color: var(--accent); font-style: normal; }
.mascot-avatar { border-radius: 50%; object-fit: cover; flex-shrink: 0; display: block; }
.header-search { flex: 1 1 220px; display: flex; max-width: 420px; }
.header-search input {
  flex: 1; border: 2px solid var(--line); border-right: none; border-radius: 999px 0 0 999px;
  padding: 8px 16px; font-size: 0.95rem; background: #fff; color: var(--ink); min-width: 0;
}
.header-search input:focus { outline: 2px solid var(--accent-2); outline-offset: -2px; }
.header-search button {
  border: 2px solid var(--line); border-left: none; background: var(--ink); color: #fff;
  border-radius: 0 999px 999px 0; padding: 0 16px; cursor: pointer;
}
.header-nav { display: flex; gap: 1.1rem; margin-left: auto; }
.header-nav a { color: var(--ink); text-decoration: none; font-weight: 600; }
.header-nav a:hover { color: var(--accent); }

/* -- Hero -- */
.hero { padding: 3.2rem 0 2rem; text-align: center; }
.hero h1 { margin-bottom: 0.3em; }
.hero-sub { font-size: 1.1rem; max-width: 42ch; margin: 0 auto; }
.hero-art { display: block; width: 100%; max-width: 640px; height: auto; margin: 1.8rem auto 0; }

/* -- Sections -- */
.section { padding: 2.2rem 0; }
.section.alt { background: var(--paper-alt); }
.section-sub { margin-top: -0.4em; }
.section-cta { margin-top: 1rem; }
.section-cta a { font-weight: 700; text-decoration: none; }
.page-wrap { padding: 2rem 0 3.5rem; }

/* -- Card grid -- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  margin-top: 1.2rem;
}
.game-card {
  display: flex; flex-direction: column;
  background: var(--card-bg);
  border: 3px solid var(--card-accent, var(--accent));
  border-radius: 14px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: 4px 4px 0 rgba(32, 31, 29, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.game-card:hover, .game-card:focus-visible { transform: translateY(-3px) rotate(-1deg); box-shadow: 6px 9px 0 rgba(32, 31, 29, 0.12); }
.game-thumb { position: relative; display: block; background: var(--paper-alt); }
.game-thumb img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.placeholder-thumb {
  width: 100%; aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--card-accent, var(--accent)) 18%, white);
}
.placeholder-thumb .mascot-avatar { box-shadow: 0 3px 0 rgba(32, 31, 29, 0.12); }
.status-badge {
  position: absolute; left: 8px; top: 8px;
  background: var(--card-accent, var(--accent)); color: #fff;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.02em;
  padding: 3px 9px; border-radius: 999px;
}
.status-badge-lg { position: static; display: inline-block; margin-bottom: 0.6em; font-size: 0.8rem; padding: 5px 14px; }
.game-title { font-weight: 700; font-size: 0.92rem; padding: 10px 10px 2px; }
.game-cat { font-size: 0.78rem; color: var(--ink-soft); padding: 0 10px 10px; margin-top: auto; }

/* -- Category tiles -- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.9rem; margin-top: 1.2rem; }
.cat-tile {
  display: flex; align-items: center; gap: 0.8rem;
  background: var(--card-bg); border-left: 6px solid var(--card-accent, var(--accent));
  border-radius: var(--radius-sm); padding: 0.8rem 1.2rem;
  text-decoration: none; color: var(--ink);
  box-shadow: 3px 3px 0 rgba(32, 31, 29, 0.06);
  transition: transform 0.15s ease;
}
.cat-tile:hover { transform: translateX(3px); }
.cat-tile-icon { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; }
.cat-tile-icon-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex-shrink: 0;
  background: var(--paper-alt); border-radius: 10px;
}
.cat-tile-text { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.cat-tile-name { font-weight: 700; }
.cat-tile-count { font-size: 0.8rem; color: var(--ink-soft); }

/* -- Buttons -- */
.btn {
  display: inline-block; border: none; cursor: pointer; font-weight: 700;
  padding: 10px 22px; border-radius: var(--wobble); text-decoration: none;
  font-family: inherit; font-size: 0.95rem;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #d63639; }

/* -- Breadcrumbs -- */
.breadcrumbs { font-size: 0.82rem; color: var(--ink-soft); margin-bottom: 1rem; }
.breadcrumbs a { color: var(--ink-soft); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); }
.crumb-sep { margin: 0 6px; opacity: 0.5; }

/* -- Game page -- */
.game-page h1 { margin-bottom: 0.15em; }
.game-tagline { font-size: 1.05rem; margin-top: 0; }
.play-frame {
  position: relative; width: 100%; aspect-ratio: var(--aspect, 4/3); max-height: 78vh;
  border-radius: var(--radius); overflow: hidden; background: #111;
  box-shadow: 5px 6px 0 rgba(32, 31, 29, 0.12);
  margin: 1.2rem 0;
}
.play-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.play-frame-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  background: color-mix(in srgb, var(--card-accent, var(--accent)) 15%, white);
  padding: 2rem;
}
.play-frame-placeholder p { max-width: 48ch; }
.game-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.4rem; }
.chip {
  display: inline-block; background: var(--paper-alt); border: 1.5px solid var(--line);
  color: var(--ink-soft); font-size: 0.78rem; font-weight: 600;
  padding: 5px 12px; border-radius: 999px; text-decoration: none;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip-cat { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip-cat:hover { color: #fff; opacity: 0.9; }
.chip-origin { background: #fff; }
.game-description, .game-instructions { max-width: 72ch; }
.game-source { font-size: 0.8rem; color: var(--ink-soft); font-style: italic; }

/* -- Pagination -- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 1.4rem; margin-top: 2.2rem; }
.page-link { font-weight: 700; text-decoration: none; }
.page-status { color: var(--ink-soft); font-size: 0.85rem; }

/* -- Search page -- */
.search-page-input {
  width: 100%; max-width: 520px; padding: 12px 18px; font-size: 1.05rem;
  border: 2.5px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink);
}
.search-page-input:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }
#search-status { color: var(--ink-soft); font-size: 0.9rem; margin-top: 0.8rem; }
.search-empty-state { text-align: center; padding: 1.6rem 0 1rem; }
.search-empty-state img { display: block; width: 100%; max-width: 240px; height: auto; margin: 0 auto 1rem; }
.search-empty-state p { max-width: 42ch; margin: 0 auto; }

/* -- Simple content pages -- */
.content-page { max-width: 68ch; }
.content-page h2 { margin-top: 1.6em; }
.about-page { max-width: 800px; }
.about-hero { display: flex; align-items: center; gap: 1.8rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.about-art { width: 190px; height: 190px; object-fit: cover; border-radius: var(--radius); flex-shrink: 0; box-shadow: 4px 4px 0 rgba(32, 31, 29, 0.08); }
.about-hero > div { flex: 1 1 320px; min-width: 280px; }
.about-hero h1 { margin-bottom: 0.4em; }

/* -- 404 / not-found -- */
.not-found-page { text-align: center; padding-top: 1rem; }
.not-found-art { display: block; width: 100%; max-width: 320px; height: auto; margin: 0 auto 1.2rem; }
.not-found-page p { max-width: 46ch; margin: 0 auto; }

/* -- Footer -- */
.site-footer { border-top: 3px solid var(--line); background: var(--paper-alt); padding: 2.4rem 0 1.2rem; margin-top: 2rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 2rem; justify-content: space-between; align-items: flex-start; }
.footer-brand p { margin-top: 0.5em; max-width: 32ch; }
.footer-links { display: flex; flex-direction: column; gap: 0.5rem; }
.footer-links a { color: var(--ink); text-decoration: none; font-weight: 600; font-size: 0.92rem; }
.footer-links a:hover { color: var(--accent); }
.footer-copy { max-width: 1180px; margin: 1.8rem auto 0; padding: 0 20px; font-size: 0.75rem; color: var(--ink-soft); }

/* -- Consent banner -- */
.consent-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--ink); color: #fff;
}
.consent-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; padding: 14px 20px; justify-content: space-between; }
.consent-banner p { color: #E7E4DC; margin: 0; font-size: 0.85rem; max-width: 60ch; }
.consent-banner a { color: #fff; text-decoration: underline; }

@media (max-width: 640px) {
  .header-nav { order: 3; width: 100%; justify-content: center; margin-left: 0; }
  .hero { padding: 2.2rem 0 1.4rem; }
}
