/* Two Tone Arcade — shared styles (home + play pages). Ozsly LLC © 2026 */
:root {
  --bg: #FAF9F6;
  --bg-alt: #F0EFEA;
  --ink: #111111;
  --ink-muted: #4A4A4A;
  --border: #111111;
  --border-subtle: #D9D6CC;
  --shadow: 4px 4px 0 #111111;
  --shadow-sm: 2px 2px 0 #111111;
  --mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
html.dark {
  --bg: #121212;
  --bg-alt: #1C1C1C;
  --ink: #F2F2F2;
  --ink-muted: #BDBDBD;
  --border: #F2F2F2;
  --border-subtle: #3A3A3A;
  --shadow: 4px 4px 0 #F2F2F2;
  --shadow-sm: 2px 2px 0 #F2F2F2;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;           /* 16px base */
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: var(--ink); text-underline-offset: 3px; }

/* Visible focus for keyboard users */
:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}
a:focus:not(:focus-visible), button:focus:not(:focus-visible) { outline: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: 8px; top: -100px;
  z-index: 100;
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  padding: 12px 16px;
  min-height: 48px;
  text-decoration: none;
}
.skip-link:focus { top: 8px; outline-color: var(--ink); }

/* Buttons & button-like links (>=48px tap targets) */
.btn {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--bg);
  border: 2px solid var(--border);
  min-height: 48px;
  min-width: 48px;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  border-radius: 0;
}
.btn:hover { background: var(--bg-alt); }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.btn-primary {
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
}
.btn-primary:hover { background: var(--ink); color: var(--bg); transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--border-subtle); }

/* White-alpha 1-bit sprites: invert to ink in light mode */
.art-sprite { display: block; image-rendering: pixelated; filter: invert(1); width: 20px; height: 20px; flex-shrink: 0; }
html.dark .art-sprite { filter: none; }
.btn[aria-pressed="true"] .art-sprite { filter: none; }
html.dark .btn[aria-pressed="true"] .art-sprite { filter: invert(1); }

/* ===== Header ===== */
.site-header {
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  padding: 8px 16px;
}
.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  flex-wrap: wrap;
}
.brand-link {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  color: var(--ink);
  text-decoration: none;
}
.brand-svg { width: 212px; height: 36px; display: block; color: var(--ink); }

/* ===== Home ===== */
.home-main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 16px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.home-title {
  font-family: var(--mono);
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  line-height: 1.2;
  font-weight: 800;
  text-align: center;
  margin: 0 0 32px;
  letter-spacing: -0.01em;
  max-width: 22ch;
}
.tile-grid {
  --cols: 2;
  --gap: 16px;
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gap);
}
.tile-grid > li {
  flex: 0 0 calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols));
  min-width: 0;
}
@media (min-width: 600px) { .tile-grid { --cols: 3; --gap: 24px; } }
@media (min-width: 1000px) { .tile-grid { --cols: 4; --gap: 28px; } }

.tile {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  padding: 0;
}
.tile-art {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
  background: var(--bg);
  transition: transform .12s ease, box-shadow .12s ease;
}
.tile:hover .tile-art, .tile:focus-visible .tile-art { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--border); }
.tile-name {
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
}
.tile-tag {
  align-self: center;
  font-size: 1rem;
  font-weight: 700;
  border: 2px solid var(--border);
  padding: 2px 10px;
  line-height: 1.4;
}
.tile-tag.is-play { background: var(--ink); color: var(--bg); }
.tile:focus-visible { outline-offset: 6px; }

.home-cta { margin-top: 40px; font-size: 1.25rem; padding: 14px 28px; min-height: 56px; }

/* ===== Footer ===== */
.site-footer {
  border-top: 2px solid var(--border);
  padding: 12px 16px;
}
.footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px 8px;
}
.footer-inner ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 4px; }
.footer-inner a {
  display: inline-flex; align-items: center;
  min-height: 48px; padding: 0 10px;
  font-weight: 700;
}
.footer-copy { color: var(--ink-muted); padding: 0 10px; }

/* ===== Play page ===== */
.play-header .header-inner { justify-content: flex-start; }
.back-link { white-space: nowrap; }
.play-title {
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}
.play-title small { font-size: 1rem; font-weight: 700; color: var(--ink-muted); margin-left: 6px; white-space: nowrap; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; }
.tools .btn { padding: 8px 12px; }

.play-main {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stage-workspace {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 28px;   /* 28 + 1px rule + 28 = 57px clearance (>= 40px desktop rule) */
}
.stage-rail-divider { width: 1px; height: 640px; background: var(--border-subtle); flex: 0 0 1px; }
.stage-column { display: flex; flex-direction: column; align-items: center; flex: 0 0 auto; }
.game-stage-shell {
  width: 420px;
  height: clamp(580px, calc(100vh - 120px), 680px);
  background: var(--bg);
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.game-stage-shell:fullscreen { width: 100vw; height: 100vh; border: 0; box-shadow: none; }
.game-iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--bg); }

/* Ads */
.ad-rail { flex: 0 0 160px; width: 160px; display: flex; flex-direction: column; align-items: center; }
.ad-label {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin-bottom: 6px;
  text-align: center;
}
.ad-frame-160x600, .ad-frame-320x50 {
  background: var(--bg-alt);
  border: 2px solid var(--border);
  overflow: hidden;
  position: relative;
}
.ad-frame-160x600 { width: 160px; height: 600px; display: flex; flex-direction: column; }
.ad-frame-320x50 { width: 320px; max-width: 100%; height: 50px; display: flex; align-items: center; justify-content: center; }
.mobile-ad-wrap {
  display: none;
  flex-direction: column;
  align-items: center;
  margin-top: 28px;          /* >= 24px from the game frame */
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  width: 100%;
}

/* Preview (house) ad content rendered by ad-config.js */
.ad-preview-inner {
  width: 100%; height: 100%;
  padding: 14px 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  text-align: center; font-size: 0.875rem;
}
.ad-spec-pill { width: 100%; font-size: 0.75rem; font-weight: 800; padding: 4px; border: 2px solid var(--border); background: var(--bg); }
.ad-house-art { color: var(--ink); }
.ad-house-kicker { font-size: 0.75rem; letter-spacing: 0.1em; color: var(--ink-muted); font-weight: 700; }
.ad-house-title { font-family: var(--mono); font-size: 1rem; font-weight: 900; border-bottom: 2px solid var(--border); padding-bottom: 4px; width: 100%; }
.ad-house-desc { font-size: 0.875rem; line-height: 1.4; margin: 4px 0; }
.ad-tip-box { width: 100%; border: 2px solid var(--border); padding: 8px 6px; background: var(--bg); text-align: left; }
.ad-tip-title { font-size: 0.75rem; font-weight: 900; letter-spacing: 0.1em; }
.ad-tip-text { font-size: 0.8125rem; line-height: 1.35; }
.ad-house-cta {
  width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: center;
  font-weight: 900; background: var(--ink); color: var(--bg); text-decoration: none; border: 2px solid var(--border);
}
.ad-meta { display: flex; flex-direction: column; gap: 2px; width: 100%; border-top: 1px dashed var(--border-subtle); padding-top: 6px; font-size: 0.75rem; color: var(--ink-muted); }
.ad-mobile-preview-inner { width: 100%; height: 100%; padding: 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.8125rem; }
.ad-spec-pill-sm { font-size: 0.75rem; font-weight: 800; padding: 2px 5px; border: 2px solid var(--border); background: var(--bg); white-space: nowrap; }
.ad-mobile-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Play another */
.more-games { width: 100%; max-width: 720px; margin-top: 32px; text-align: center; }
.more-games h2 { font-family: var(--mono); font-size: 1.125rem; margin: 0 0 12px; }
.more-list { list-style: none; margin: 0; padding: 0; display: flex; justify-content: center; flex-wrap: wrap; gap: 16px; }
.more-list .tile { width: 112px; gap: 6px; }
.more-list .tile-art { box-shadow: var(--shadow-sm); }
.more-list .tile-name { font-size: 1rem; }
.more-list .tile[aria-current="page"] .tile-name::after { content: " (playing)"; font-weight: 400; }

/* ===== Responsive ===== */
@media (max-width: 959px) {
  .ad-rail, .stage-rail-divider { display: none !important; }
  .mobile-ad-wrap { display: flex; }
  .stage-workspace { gap: 0; }
}
@media (max-width: 520px) {
  .site-header { padding: 6px 8px; }
  .brand-svg { width: 168px; height: 29px; }
  .play-main { padding: 8px 8px 24px; }
  .tools { gap: 6px; }
  .tools .btn { padding: 8px 10px; }
  .tools .tool-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .game-stage-shell {
    width: min(100vw - 16px, 412px);
    height: clamp(600px, calc(100dvh - 40px), 680px);  /* iframe >= 560px on phones */
  }
  .mobile-ad-wrap { margin-top: 24px; }
  .home-main { padding-top: 24px; }
}
@media (max-width: 399px) {
  .open-tab-text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .btn-primary:hover, .tile:hover .tile-art, .tile:focus-visible .tile-art { transform: none; }
}
