:root {
  color-scheme: dark;
  --bg: #05070c;
  --panel: #0d121c;
  --panel-2: #121a26;
  --line: #26354a;
  --text: #ecf4ff;
  --muted: #91a3ba;
  --accent: #39e7d6;
  --amber: #ffd166;
  --good: #68ef9d;
  --danger: #ff6b7a;
  --blue: #69a7ff;
  --shadow: rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 20% -10%, rgba(57,231,214,.12), transparent 30rem),
    radial-gradient(circle at 90% 12%, rgba(169,135,255,.10), transparent 28rem),
    linear-gradient(180deg, #070a11, var(--bg));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

code, pre, .mono, button, .chip-title {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.site-header {
  border-bottom: 1px solid rgba(145,163,186,.18);
  background: rgba(5,7,12,.84);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  width: min(1240px, calc(100% - 32px));
  min-height: 70px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand { display:flex; align-items:center; gap:13px; color:inherit; text-decoration:none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  color: var(--accent);
  font: 800 12px/1 ui-monospace, monospace;
  letter-spacing:.08em;
  box-shadow: inset 0 0 22px rgba(57,231,214,.08), 0 0 24px rgba(57,231,214,.08);
}
.brand strong { display:block; font-size:16px; }
.brand span { display:block; color:var(--muted); font-size:12px; }
.back-link { min-width:44px; min-height:44px; display:inline-flex; align-items:center; justify-content:center; text-decoration:none; border:1px solid var(--line); border-radius:999px; padding:9px 13px; color:var(--accent); font-size:12px; }
.game-switcher { border-top:1px solid rgba(145,163,186,.12); overflow:hidden; }
.game-switcher-inner { width:min(1240px,calc(100% - 32px)); margin:auto; min-height:58px; display:flex; align-items:stretch; gap:5px; overflow-x:auto; overscroll-behavior-inline:contain; scrollbar-width:none; }
.game-switcher-inner::-webkit-scrollbar { display:none; }
.game-switcher-label { flex:0 0 auto; padding:0 11px 0 0; display:grid; place-items:center; color:var(--muted); font:800 9px/1 ui-monospace,monospace; letter-spacing:.12em; }
.game-switcher a { flex:0 0 auto; min-width:128px; min-height:50px; padding:8px 12px; border-bottom:2px solid transparent; display:grid; align-content:center; gap:4px; color:#cad6e5; text-decoration:none; font:800 11px/1.1 ui-monospace,monospace; }
.game-switcher a small { color:var(--muted); font:700 8px/1 ui-monospace,monospace; letter-spacing:.08em; }
.game-switcher a:hover { background:rgba(255,255,255,.035); color:var(--accent); }
.game-switcher a[aria-current="page"] { border-bottom-color:var(--accent); background:rgba(57,231,214,.075); color:var(--accent); }
.game-switcher a[aria-current="page"] small { color:var(--accent); }

.status-pill {
  border: 1px solid #315c43;
  background: #10261a;
  color: var(--good);
  border-radius: 999px;
  padding: 7px 10px;
  font: 700 11px/1.2 ui-monospace, monospace;
  white-space: nowrap;
}

.page {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 64px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr);
  gap: 24px;
  margin-bottom: 24px;
}

.panel {
  min-width:0;
  background: linear-gradient(145deg, rgba(18,26,38,.95), rgba(9,14,22,.95));
  border: 1px solid rgba(145,163,186,.18);
  border-radius: 18px;
  box-shadow: 0 24px 80px var(--shadow);
}

.intro-copy { padding:clamp(24px,5vw,54px); position:relative; overflow:hidden; }
.intro-copy::after { content:""; position:absolute; width:280px; height:280px; border:1px solid rgba(57,231,214,.16); border-radius:50%; right:-120px; top:-120px; box-shadow:0 0 0 32px rgba(57,231,214,.025),0 0 0 64px rgba(57,231,214,.018); }
.eyebrow { color: var(--accent); font: 700 11px/1.3 ui-monospace, monospace; letter-spacing: .13em; text-transform: uppercase; }
.intro h1 { margin:12px 0 14px; font-size:clamp(32px,5vw,64px); line-height:.98; letter-spacing:-.025em; }
.intro h1 span { color:#fff; }
.intro .lead { margin:0; max-width:760px; color:#bfd0e5; font-size:clamp(16px,2vw,21px); line-height:1.55; }
.hero-tags { display:flex; flex-wrap:wrap; gap:8px; margin-top:20px; }
.tag { border:1px solid var(--line); color:var(--muted); border-radius:999px; padding:7px 10px; font:700 11px/1 ui-monospace,monospace; }

.spec-card { padding:22px; display:grid; gap:10px; align-content:center; }
.spec-row { display:flex; justify-content:space-between; gap:20px; padding:10px 0; border-bottom:1px solid rgba(145,163,186,.12); font-size:13px; }
.spec-row:last-child { border:0; }
.spec-row span { color:var(--muted); }
.spec-row strong { text-align:right; }

.lab-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, .75fr);
  gap: 24px;
  align-items: start;
}

.game-panel { padding: 14px; }
.panel-titlebar { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 12px; }
.panel-titlebar h3 { margin: 0; font-size: 14px; letter-spacing: .04em; }
.panel-titlebar .sub { color: var(--muted); font: 11px ui-monospace, monospace; }

.crt-shell {
  position: relative;
  padding: 12px;
  border: 1px solid #303848;
  border-radius: 14px;
  background: #030507;
  box-shadow: inset 0 0 35px rgba(0,0,0,.75), 0 10px 30px rgba(0,0,0,.3);
  overflow: hidden;
}

.crt-shell::after {
  content: "";
  position: absolute;
  inset: 12px;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,.025) 0, rgba(255,255,255,.025) 1px, rgba(0,0,0,.035) 2px, rgba(0,0,0,.035) 3px);
  mix-blend-mode: overlay;
  border-radius: 3px;
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 320 / 224;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  border-radius: 3px;
}
#game-canvas[data-quality="crisp"] { filter: saturate(1.08) contrast(1.05); }
#game-canvas[data-quality="neon"] { filter: saturate(1.22) contrast(1.08) drop-shadow(0 0 5px rgba(57,231,214,.22)); }

.controls {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

button, .toggle, .select-control {
  border: 1px solid #33445d;
  background: #131d2a;
  color: var(--text);
  border-radius: 9px;
  min-height: 44px;
  padding: 10px 13px;
  font-size: 11px;
}
button { cursor: pointer; }
select { border:0; background:#0b111a; color:var(--accent); font:800 10px/1 ui-monospace,monospace; padding:5px 4px; border-radius:5px; }
.select-control { display:inline-flex; gap:7px; align-items:center; color:var(--muted); font:800 10px/1 ui-monospace,monospace; }
button:hover { border-color: #65758f; background: #202a3b; }
button:active { transform: translateY(1px); }
button.primary { border-color: var(--accent); color: var(--accent); background: rgba(57,231,214,.06); }
.toggle { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; }
.toggle input { accent-color: var(--accent); }

.control-help {
  margin:13px 0 0; padding:11px 12px; display:flex; flex-wrap:wrap; align-items:center; gap:7px 9px;
  border:1px solid rgba(145,163,186,.14); border-radius:10px; background:rgba(5,8,13,.56);
  color:var(--muted); font-size:12px; line-height:1.5;
}
.control-group { display:inline-flex; flex-wrap:wrap; align-items:center; gap:5px; }
.key-cluster { display:inline-flex; flex-wrap:wrap; align-items:center; gap:3px; }
.control-help kbd { display:inline-grid; place-items:center; min-width:26px; min-height:24px; padding:2px 6px; border:1px solid #46546a; border-bottom-width:2px; border-radius:5px; background:#101620; color:#e8edf4; font:800 10px/1 ui-monospace,monospace; box-shadow:inset 0 -1px rgba(255,255,255,.04); }
.key-join { color:#718198; font-size:10px; }
.control-action { color:#c7d4e4; }
.control-divider { color:#526178; }
.control-goal { flex-basis:100%; padding-top:8px; border-top:1px solid rgba(145,163,186,.10); color:#91a3ba; }

.inspector { overflow: hidden; }
.inspector-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.inspector-head h3 { margin: 0; font-size: 14px; }
.led { width: 9px; height: 9px; border-radius: 50%; background: var(--good); box-shadow: 0 0 10px rgba(85,224,128,.8); }
.led.paused { background: var(--amber); box-shadow: 0 0 10px rgba(255,209,102,.55); }
.led.error { background: var(--danger); box-shadow: 0 0 10px rgba(255,107,114,.8); }

.stat-section { padding: 13px 16px; border-bottom: 1px solid var(--line); }
.stat-section:last-child { border-bottom: 0; }
.stat-section h4 { margin: 0 0 9px; color: var(--muted); font: 700 10px/1.2 ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px 12px; }
.stat { min-width: 0; }
.stat label { display: block; color: #8190a3; font-size: 10px; }
.stat output { display: block; overflow: hidden; text-overflow: ellipsis; color: #f2f5f8; font: 12px/1.4 ui-monospace, monospace; }
.registers { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; }
.reg { border: 1px solid #2d394b; background: #0d121b; padding: 5px; text-align: center; }
.reg span { display: block; color: #75849a; font-size: 9px; }
.reg b { font: 11px ui-monospace, monospace; }
.trace { margin: 0; max-height: 104px; overflow: auto; color: #bac5d3; font: 10px/1.45 ui-monospace, monospace; white-space: pre; }

.section { margin-top: 24px; padding: 18px; }
.section h2, .section h3 { margin:0 0 8px; }
.section h2 { font-size:24px; }
.section > p { margin: 0 0 14px; color: var(--muted); }
.section-kicker { color:var(--accent); font:800 10px/1.2 ui-monospace,monospace; letter-spacing:.16em; margin-bottom:7px; }

.pipeline {
  display: grid;
  grid-template-columns: repeat(7, auto);
  align-items: stretch;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.pipe-box {
  min-width: 132px;
  border: 1px solid #344158;
  background: #0d131d;
  padding: 12px;
  border-radius: 7px;
}
.pipe-box strong { display: block; color: #f2f5f8; font-size: 12px; }
.pipe-box span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.pipe-arrow { align-self: center; color: var(--accent); font: 18px ui-monospace, monospace; }

.version-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.version-card { border:1px solid var(--line); border-radius:12px; padding:16px; background:#0d131d; }
.version-card.current { border-color:rgba(57,231,214,.55); box-shadow:inset 0 0 30px rgba(57,231,214,.04); }
.version-card span { display:block; color:var(--accent); font:800 10px/1.2 ui-monospace,monospace; letter-spacing:.1em; }
.version-card strong { display:block; margin-top:7px; }
.version-card p { margin:7px 0 13px; color:var(--muted); font-size:12px; }
.version-card a { color:var(--amber); font:800 10px/1 ui-monospace,monospace; }
.sprite-section { overflow:hidden; }
#sprite-atlas { display:block; width:min(100%,768px); height:auto; margin-top:12px; border:1px solid var(--line); border-radius:9px; background:#080c12; image-rendering:pixelated; image-rendering:crisp-edges; }

.rom-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.rom-chip { position: relative; min-height: 136px; border: 1px solid #3a465a; border-radius: 8px; padding: 17px 13px 14px; background: linear-gradient(135deg, #151b24, #090d13); overflow: hidden; }
.rom-chip::before, .rom-chip::after { content:""; position:absolute; left:8px; right:8px; height:4px; background: repeating-linear-gradient(90deg, #5f6874 0 4px, transparent 4px 9px); opacity:.5; }
.rom-chip::before { top: 3px; }
.rom-chip::after { bottom: 3px; }
.chip-title { color: var(--amber); font-weight: 800; font-size: 12px; }
.chip-role { display:block; color:#c3ccd8; font-size:11px; margin:6px 0; }
.chip-meta { color:#7f8da0; font:9px/1.5 ui-monospace, monospace; word-break:break-all; }
.rom-chip button { margin-top: 9px; min-height: 34px; padding: 7px 9px; font-size: 9px; }

.code-layout { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 12px; }
.code-card { min-width: 0; }
.code-card h4 { margin: 0 0 7px; font-size: 12px; color: #cfd7e3; }
pre {
  margin: 0;
  border: 1px solid #2c3749;
  border-radius: 7px;
  background: #080c12;
  padding: 13px;
  color: #c7d2df;
  overflow: auto;
  max-height: 420px;
  font-size: 10px;
  line-height: 1.5;
  tab-size: 4;
}

.memory-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.memory-table th, .memory-table td { border-bottom: 1px solid #293446; padding: 8px 9px; text-align: left; vertical-align: top; }
.memory-table th { color: #8e9bad; font: 700 10px ui-monospace, monospace; }
.memory-table td:first-child { color: var(--accent); font-family: ui-monospace, monospace; white-space: nowrap; }
.memory-table td:nth-child(2) { color: #d5dce5; }
.memory-table td:last-child { color: var(--muted); }

.note {
  margin-top: 14px;
  padding: 12px 14px;
  border-left: 3px solid var(--amber);
  background: #17150d;
  color: #d9d1b7;
  font-size: 12px;
}

.hex-title { display:flex; justify-content:space-between; gap:12px; align-items:center; margin-bottom:8px; }
.hex-title strong { font: 12px ui-monospace, monospace; color:var(--accent); }

.footer { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); color: #7f8da0; font-size: 11px; }

@media (max-width: 1050px) {
  .intro, .lab-grid { grid-template-columns: 1fr; }
  .lab-grid { gap: 12px; }
  .inspector { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .inspector-head { grid-column: 1/-1; }
  .stat-section { border-right: 1px solid var(--line); }
}

@media (max-width: 760px) {
  .page, .header-inner { width:min(100% - 20px,1240px); }
  .game-switcher-inner { width:min(100% - 20px,1240px); }
  .game-switcher-label { position:sticky; z-index:2; left:0; padding-inline:8px 12px; background:#070a11; }
  .game-switcher a { min-width:118px; }
  .page { padding:24px 0 50px; }
  .back-link span, .status-pill { display:none; }
  .game-panel, .section { padding: 12px; }
  .intro-copy { padding:25px 20px; }
  .inspector { display: block; }
  .rom-grid { grid-template-columns: 1fr 1fr; }
  .code-layout { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: 1fr; }
  .pipe-arrow { transform: rotate(90deg); justify-self:center; }
  .control-help { align-items:flex-start; }
  .control-group { flex-basis:100%; }
  .control-divider { display:none; }
  .version-grid { grid-template-columns:1fr; }
}

@media (max-width: 480px) {
  .rom-grid { grid-template-columns: 1fr; }
  .controls { display:grid; grid-template-columns:1fr 1fr; }
  .controls > * { min-width:0; width:100%; padding-inline:8px; }
  .select-control select { min-width:0; max-width:100%; }
}


/* Identidade Shiu.com.br */
.brand:hover strong { color: var(--accent); }
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 4px; }
.footer { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: space-between; }
.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
@media (max-width: 760px) {
  .footer { display: grid; }
}


.touch-controls {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 10px;
  padding: 12px 12px max(12px, env(safe-area-inset-bottom));
  border: 1px solid rgba(86, 231, 210, .2);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(86, 231, 210, .055), rgba(9, 14, 22, .96));
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.touch-dpad {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(2, 48px);
  gap: 6px;
}
.touch-key {
  min-width: 48px;
  min-height: 48px;
  border-radius: 10px;
  font-size: 16px;
  touch-action: none;
}
.touch-actions { display:grid; gap:8px; align-content:center; }
.touch-key.pressed,
.touch-key:active {
  border-color: var(--accent);
  background: #30270f;
  color: var(--accent);
  transform: translateY(1px);
}
.touch-up { grid-column: 2; grid-row: 1; }
.touch-left { grid-column: 1; grid-row: 2; }
.touch-down { grid-column: 2; grid-row: 2; }
.touch-right { grid-column: 3; grid-row: 2; }
.touch-attack {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border-color: #704047;
  background: #291218;
  color: #ffb9bd;
  font-size: 12px;
}
@media (hover: none), (pointer: coarse), (max-width: 720px) {
  .touch-controls { display: flex; }
}
@media (max-width: 360px) {
  .touch-controls { gap: 8px; padding-inline: 8px; }
  .touch-dpad { grid-template-columns: repeat(3, 42px); grid-template-rows: repeat(2, 42px); gap: 4px; }
  .touch-key { min-width: 42px; min-height: 42px; }
  .touch-attack { width: 78px; height: 78px; }
}
.skip-link { position:fixed; z-index:100; top:10px; left:10px; min-height:44px; padding:9px 12px; display:flex; align-items:center; border-radius:6px; background:var(--accent); color:#080b11; font-weight:800; transform:translateY(-160%); }
.skip-link:focus { transform:translateY(0); }
:focus-visible { outline:3px solid var(--accent); outline-offset:3px; }
.library-link { min-height:44px; padding:8px 11px; display:inline-flex; align-items:center; color:#9eb2c8; text-decoration:none; border:1px solid #2c3b50; border-radius:999px; font:700 11px ui-monospace,monospace; }
.footer a { min-height:44px; display:inline-flex; align-items:center; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior:auto; }
  *, *::before, *::after { animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important; }
}
