/* ============================================================
   richolson-star-castle — hand-written scoped overrides
   ------------------------------------------------------------
   Atomic prepends the compiled Tailwind v4 bundle ABOVE this block.
   Scoped, hand-authored rules only:
     1. palette tokens (flip under a .dark ancestor — class-based dark
        mode owned by the site shell). The <canvas> reads these at
        runtime so the game re-themes with the site;
     2. canvas presentation + a cosmetic CRT scanline/vignette layer;
     3. the on-screen touch control pad.
   Scoped under .custom-section-richolson-star-castle so nothing leaks.
   ============================================================ */
.custom-section-richolson-star-castle.ro-castle-site {
  --bg: oklch(0.985 0.008 160);
  --surface: oklch(0.965 0.012 175);
  --surface-2: oklch(0.93 0.016 180);
  --text: oklch(0.24 0.022 165);
  --muted: oklch(0.47 0.024 200);
  --line: oklch(0.88 0.015 175);
  --accent: oklch(0.55 0.14 158);
  --accent-ghost: oklch(0.55 0.14 158 / 0.4);
  --accent2: oklch(0.55 0.13 245);
  --on-accent: oklch(0.99 0.01 160);
  --code-bg: oklch(0.95 0.012 178);
  --danger: oklch(0.55 0.2 25);

  --font-sans: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: block;
  min-height: 100vh;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .4s ease, color .4s ease;
}

.dark .custom-section-richolson-star-castle.ro-castle-site {
  --bg: oklch(0.16 0.012 160);
  --surface: oklch(0.205 0.016 162);
  --surface-2: oklch(0.245 0.02 162);
  --text: oklch(0.945 0.015 150);
  --muted: oklch(0.72 0.02 150);
  --line: oklch(0.31 0.02 160);
  --accent: oklch(0.82 0.16 150);
  --accent-ghost: oklch(0.82 0.16 150 / 0.5);
  --accent2: oklch(0.87 0.15 96);
  --on-accent: oklch(0.17 0.02 160);
  --code-bg: oklch(0.125 0.012 160);
  --danger: oklch(0.66 0.18 25);
}

.custom-section-richolson-star-castle.ro-castle-site ::selection { background: var(--accent); color: var(--on-accent); }

.section-wrapper:has(.custom-section-richolson-star-castle.ro-castle-site > header.fixed) {
  z-index: 100;
}

.custom-section-richolson-star-castle.ro-castle-site .ro-shell-menu summary {
  list-style: none;
}

.custom-section-richolson-star-castle.ro-castle-site .ro-shell-menu summary::-webkit-details-marker {
  display: none;
}

.custom-section-richolson-star-castle.ro-castle-site .ro-shell-menu[open] summary {
  border-color: var(--accent);
}

.custom-section-richolson-star-castle button:not(:disabled),
.custom-section-richolson-star-castle a[href][class*="rounded"] {
  touch-action: manipulation;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease, border-color .12s ease;
}

.custom-section-richolson-star-castle button:not(:disabled):active,
.custom-section-richolson-star-castle a[href][class*="rounded"]:active {
  transform: translateY(2px) scale(0.975);
  box-shadow: inset 0 2px 9px color-mix(in oklab, var(--text) 26%, transparent);
  filter: brightness(0.96);
}

@keyframes ro-castle-glow { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
.custom-section-richolson-star-castle.ro-castle-site .ro-glow { animation: ro-castle-glow 1.6s ease-in-out infinite; }

.custom-section-richolson-star-castle.ro-castle-site [data-stage] {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  background: var(--code-bg);
  border: 1px solid var(--line);
}
.custom-section-richolson-star-castle.ro-castle-site [data-canvas] {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.custom-section-richolson-star-castle.ro-castle-site [data-crt] {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, transparent 0, transparent 2px, color-mix(in oklab, var(--bg) 22%, transparent) 3px, transparent 4px),
    radial-gradient(120% 120% at 50% 50%, transparent 60%, color-mix(in oklab, var(--bg) 55%, transparent) 100%);
  mix-blend-mode: multiply;
  opacity: .5;
}
.dark .custom-section-richolson-star-castle.ro-castle-site [data-crt] { mix-blend-mode: screen; opacity: .32; }

/* overlays */
.custom-section-richolson-star-castle.ro-castle-site [data-overlay] {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  backdrop-filter: blur(3px);
  z-index: 3;
}
.custom-section-richolson-star-castle.ro-castle-site [data-overlay][hidden] { display: none; }

/* on-screen touch controls (also clickable with a mouse) */
.custom-section-richolson-star-castle.ro-castle-site [data-pad] {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  pointer-events: none;       /* only the buttons capture pointer */
}
.custom-section-richolson-star-castle.ro-castle-site [data-pad] > div { display: flex; gap: 10px; pointer-events: none; align-items: flex-end; }
.custom-section-richolson-star-castle.ro-castle-site [data-ctl] {
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: color-mix(in oklab, var(--surface) 72%, transparent);
  color: var(--text);
  backdrop-filter: blur(4px);
  cursor: pointer;
}
.custom-section-richolson-star-castle.ro-castle-site [data-ctl][data-ctl="fire"] { width: 66px; height: 66px; border-radius: 16px; }
.custom-section-richolson-star-castle.ro-castle-site [data-ctl][data-ctl="fire"] {
  border-color: color-mix(in oklab, var(--accent) 55%, var(--line));
  color: var(--accent);
}
.custom-section-richolson-star-castle.ro-castle-site [data-ctl][data-active="1"] {
  background: var(--accent); color: var(--on-accent); border-color: var(--accent);
}
.custom-section-richolson-star-castle.ro-castle-site [data-ctl] svg { width: 22px; height: 22px; }

/* touch hint (shown on coarse-pointer devices only, via the media query below) */
.custom-section-richolson-star-castle.ro-castle-site [data-touch-hint] { display: inline; }

/* hide the touch pad + touch hint on hover-capable, fine-pointer (desktop) devices */
@media (hover: hover) and (pointer: fine) {
  .custom-section-richolson-star-castle.ro-castle-site [data-pad] { display: none; }
  .custom-section-richolson-star-castle.ro-castle-site [data-touch-hint] { display: none; }
}

/* mobile fit: logical canvas width adapts in section.js, so the playfield does not stretch. */
@media (max-width: 640px) {
  .custom-section-richolson-star-castle.ro-castle-site [data-stage] {
    aspect-ratio: 10 / 9;
    border-radius: 10px;
    margin: -8px;
    width: calc(100% + 16px);
  }
  .custom-section-richolson-star-castle.ro-castle-site [data-pad] { padding: 10px 12px; }
}
