/* Nutty Pixel portal styles. No inline styles anywhere (the Content Security Policy forbids them). */
:root {
  --bg: #0d3321;
  --bg-2: #124a2e;
  --panel: #1a5a3a;
  --panel-2: #206b45;
  --edge: #061a0f;
  --ink: #fff4d6;
  --ink-soft: #d9ecd0;
  --orange: #ff8a1f;
  --orange-dark: #c9600a;
  --yellow: #ffd23f;
  --red: #ff6a4d;
  --on-orange: #1b1206;
  --focus: #ffd23f;
  --radius: 10px;
  --gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Arial Black", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  background-image: linear-gradient(var(--bg-2) 1px, transparent 1px), linear-gradient(90deg, var(--bg-2) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.55;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--yellow); text-underline-offset: 0.2em; }
a:hover { color: #fff; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 0.5em; letter-spacing: 0.01em; text-shadow: 3px 3px 0 var(--edge); }
h1 { font-size: clamp(1.8rem, 6vw, 3rem); }
h2 { font-size: clamp(1.35rem, 4vw, 1.8rem); }
p { margin: 0 0 1em; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
:focus:not(:focus-visible) { outline: none; }
main:focus { outline: none; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -100px; z-index: 2000; background: var(--yellow); color: var(--on-orange); padding: 12px 16px; border: 3px solid var(--edge); font-weight: 700; }
.skip-link:focus { top: 8px; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }

/* ---------- header / footer ---------- */
.site-header { background: var(--edge); border-bottom: 4px solid var(--orange); padding-top: env(safe-area-inset-top); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding-top: 8px; padding-bottom: 8px; }
.brand { display: inline-flex; align-items: center; gap: 12px; min-height: 48px; color: var(--ink); text-decoration: none; }
.brand img { width: 56px; height: auto; display: block; }
.brand-name { font-family: var(--font-display); font-size: 1.4rem; text-shadow: 2px 2px 0 #000; }
.nav ul { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav a { display: inline-flex; align-items: center; min-height: 48px; min-width: 48px; padding: 0 14px; color: var(--ink); text-decoration: none; font-weight: 700; border: 3px solid transparent; border-radius: var(--radius); }
.nav a:hover { background: var(--panel); }
.nav a[aria-current="page"] { border-color: var(--yellow); color: var(--yellow); }
.lang { display: inline-flex; align-items: center; gap: 8px; }
.lang select { min-height: 44px; font: inherit; color: var(--ink); background: var(--panel); border: 3px solid var(--edge); border-radius: var(--radius); padding: 0 8px; }

.site-footer { margin-top: auto; background: var(--edge); border-top: 4px solid var(--orange); padding: 20px 0 calc(20px + env(safe-area-inset-bottom)); color: var(--ink-soft); font-size: 0.95rem; }
.site-footer p { margin: 0 0 8px; }
.site-footer ul { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 0; padding: 0; }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; }

/* ---------- layout ---------- */
main { padding: 24px 0 40px; }
.hero { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; }
.hero img { width: 88px; height: 88px; image-rendering: pixelated; flex: none; }
.hero p { color: var(--ink-soft); margin: 0; max-width: 40rem; }
.hero h1 { margin-bottom: 0.25em; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; min-width: 48px; padding: 0 20px; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; border: 3px solid var(--edge); border-radius: var(--radius); box-shadow: 0 4px 0 var(--edge); background: var(--orange); color: var(--on-orange); }
.btn:hover { background: #ffa04a; color: var(--on-orange); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
.btn-secondary { background: var(--panel); color: var(--ink); }
.btn-secondary:hover { background: var(--panel-2); color: var(--ink); }

.toolbar { margin-bottom: 12px; }
.toolbar label { display: block; font-weight: 700; margin-bottom: 6px; }
.search { width: 100%; min-height: 52px; padding: 0 16px; font: inherit; font-size: 1.0625rem; color: #1a1205; background: var(--ink); border: 3px solid var(--edge); border-radius: var(--radius); box-shadow: 0 4px 0 var(--edge); }
.search::placeholder { color: #5c5236; opacity: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chip { min-height: 44px; min-width: 44px; padding: 0 16px; font: inherit; font-weight: 700; color: var(--ink); background: var(--panel); border: 3px solid var(--edge); border-radius: 999px; cursor: pointer; }
.chip:hover { background: var(--panel-2); }
.chip[aria-pressed="true"] { background: var(--yellow); color: var(--on-orange); }

.result-count { color: var(--ink-soft); min-height: 1.6em; margin: 0 0 12px; }

/* ---------- game grid ---------- */
.grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 156px), 1fr)); }
.card { display: flex; flex-direction: column; height: 100%; overflow: hidden; text-decoration: none; color: var(--ink); background: var(--panel); border: 3px solid var(--edge); border-radius: var(--radius); box-shadow: 0 5px 0 var(--edge); }
.card:hover { background: var(--panel-2); color: var(--ink); }
.card:focus-visible { outline-offset: 4px; }
.card-thumb { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--edge); border-bottom: 3px solid var(--edge); }
.card-body { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px 14px; flex: 1; }
.card-title { font-family: var(--font-display); font-size: 1.1rem; line-height: 1.2; }
.card-desc { color: var(--ink-soft); font-size: 0.92rem; line-height: 1.4; }
.badge { align-self: flex-start; padding: 2px 10px; font-size: 0.8rem; font-weight: 700; color: var(--on-orange); background: var(--orange); border: 2px solid var(--edge); border-radius: 999px; }

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .card { transition: transform 0.12s steps(3); }
  .card:hover { transform: translateY(-4px); }
}

.empty, .notice, .notfound { padding: 28px 20px; text-align: center; background: var(--panel); border: 3px dashed var(--yellow); border-radius: var(--radius); }
.empty img, .notfound img { width: 96px; height: 96px; image-rendering: pixelated; }
.empty p, .notfound p { max-width: 32rem; margin-left: auto; margin-right: auto; }
.notfound .actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ---------- play page ---------- */
.crumbs { margin-bottom: 8px; }
.crumbs a { display: inline-flex; align-items: center; min-height: 48px; padding-right: 12px; font-weight: 700; }
.player { display: flex; flex-direction: column; }
.player-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; max-width: 960px; margin: 0 auto 10px; width: 100%; }
.player-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.player-head h1 { margin: 0; font-size: clamp(1.4rem, 4vw, 2rem); }
.player .desc { color: var(--ink-soft); max-width: 46rem; margin: 14px auto 8px; text-align: center; }

.stage { position: relative; width: 100%; max-width: 960px; height: calc(100vh - 220px); height: calc(100dvh - 220px); min-height: 420px; max-height: 900px; margin: 0 auto 10px; background: #000; border: 4px solid var(--edge); border-radius: var(--radius); box-shadow: 0 6px 0 var(--edge); overflow: hidden; }
.stage-frame { display: block; width: 100%; height: 100%; border: 0; background: #000; }
.stage-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; text-align: center; background: var(--bg); }
.stage-overlay img { width: 72px; height: 72px; image-rendering: pixelated; }
.stage-overlay p { margin: 0; max-width: 28rem; }
.stage-exit { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); z-index: 5; display: none; }
.stage.is-viewport .stage-exit { display: inline-flex; }
.stage.is-fs .stage-exit { display: inline-flex; }
/* In full screen the Exit button gets its OWN strip above the game, so it never covers the game's score, lives or buttons */
.stage.is-viewport, .stage.is-fs { display: flex; flex-direction: column; }
.stage.is-viewport .stage-exit, .stage.is-fs .stage-exit { position: static; flex: none; align-self: flex-end; order: -1; margin: 6px 10px; min-height: 44px; }
.stage.is-viewport .stage-frame, .stage.is-fs .stage-frame { flex: 1 1 auto; height: auto; min-height: 0; }
@media (prefers-reduced-motion: no-preference) {
  .spinner { animation: np-bob 0.8s steps(2) infinite; }
  @keyframes np-bob { 50% { transform: translateY(-8px); } }
}

/* Fallback "full viewport" mode, used when the browser has no element fullscreen (e.g. iPhone Safari) */
.stage.is-viewport { position: fixed; inset: 0; z-index: 1000; width: 100vw; height: 100vh; height: 100dvh; max-width: none; min-height: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.stage.is-fs { width: 100vw; height: 100vh; max-width: none; border: 0; border-radius: 0; }
html.np-lock, html.np-lock body { overflow: hidden; overscroll-behavior: none; height: 100%; }

.controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.status { text-align: center; color: var(--ink-soft); min-height: 1.6em; margin: 0 0 6px; }
.help { text-align: center; color: var(--ink-soft); font-size: 0.95rem; }

/* ---------- text pages ---------- */
.prose { max-width: 44rem; }
.prose h2 { margin-top: 1.6em; }
.prose p { color: var(--ink); }
.prose p > a:not(.btn) { display: inline-flex; align-items: center; min-height: 44px; }
.prose .meta { color: var(--ink-soft); font-size: 0.95rem; }

@media (min-width: 720px) {
  .hero img { width: 120px; height: 120px; }
  .grid { gap: 20px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}
@media (max-width: 600px) {
  .brand-name { display: none; }
  .nav a { padding: 0 10px; }
  main { padding-top: 8px; }
  .crumbs { display: none; }
  .player-head h1 { font-size: 1.5rem; margin-bottom: 0.2em; }
  .controls { width: 100%; }
  .controls .btn { min-height: 48px; padding: 0 12px; flex: 1 1 auto; }
}
@media (max-width: 420px) {
  .hero { flex-direction: column; align-items: flex-start; }
  .brand-name { font-size: 1.2rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .btn, .chip, .card, .search { border-color: ButtonText; }
  .chip[aria-pressed="true"] { outline: 3px solid Highlight; }
}
