:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --surface: #151517;
  --surface-hover: #1b1b1e;
  --border: #343437;
  --border-strong: #68686c;
  --text: #f1f1f2;
  --text-muted: #aaaab0;
  --text-dim: #85858a;
  --accent: #d8a574;
  --accent-strong: #f0bd8b;
  --accent-soft: rgba(216, 165, 116, 0.12);
  --focus: #ffd09e;
  --radius: 10px;
  --max-width: 760px;
  --nav-height: 72px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 1rem);
}

body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

::selection {
  background: rgba(216, 165, 116, 0.28);
  color: var(--text);
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.65rem 0.9rem;
  border: 2px solid var(--focus);
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.15s ease;
}

.skip-link:focus { transform: translateY(0); }

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

.container {
  width: min(100% - 3rem, var(--max-width));
  margin-inline: auto;
}

.site-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--nav-height);
  border-bottom: 1px solid var(--border);
  background: rgba(11, 11, 12, 0.9);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  backdrop-filter: saturate(140%) blur(12px);
}

.nav-inner {
  display: flex;
  min-height: var(--nav-height);
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  border-radius: 4px;
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-decoration: none;
  white-space: nowrap;
}

.brand-short { display: none; }

.site-nav ul, .footer-links, .project-meta {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav ul {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.15rem;
}

.site-nav li { display: flex; }

.site-nav ul a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.site-nav ul a:hover, .site-nav ul a[aria-current="page"] {
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
}

main:focus { outline: none; }

.hero {
  padding-block: clamp(4.5rem, 11vw, 7.5rem) clamp(4rem, 9vw, 6rem);
  border-bottom: 1px solid var(--border);
}

.eyebrow, .section-label {
  margin: 0 0 1rem;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(2.35rem, 7vw, 4rem);
  font-weight: 680;
  letter-spacing: -0.045em;
  line-height: 1.05;
  text-wrap: balance;
}

.hero .lead {
  max-width: 620px;
  margin: 1.5rem 0 0;
  color: var(--text-muted);
  font-size: clamp(1.05rem, 2vw, 1.18rem);
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.68rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.button:hover {
  border-color: var(--text-muted);
  background: var(--surface-hover);
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #15100c;
}

.button-primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.button:disabled {
  border-color: var(--border);
  background: transparent;
  color: var(--text-dim);
  opacity: 0.7;
}

.content {
  padding-block: clamp(3.5rem, 8vw, 5rem);
  border-bottom: 1px solid var(--border);
  scroll-margin-top: calc(var(--nav-height) + 1rem);
}

.content h2 {
  margin: 0;
  font-size: clamp(1.55rem, 4vw, 2rem);
  font-weight: 680;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.section-intro {
  max-width: 650px;
  margin: 1rem 0 0;
  color: var(--text-muted);
  font-size: 1.04rem;
}

.text-link {
  color: var(--text);
  font-weight: 650;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

.text-link:hover { text-decoration-thickness: 2px; }

.projects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 2rem;
}

.project-card {
  min-width: 0;
  padding: 1.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.project-card.is-featured { grid-column: 1 / -1; }

.project-card.is-link {
  padding: 0;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.project-card.is-link:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  transform: translateY(-2px);
}

.project-card-link {
  display: block;
  height: 100%;
  padding: 1.4rem;
  border-radius: inherit;
  text-decoration: none;
}

.project-kicker {
  margin: 0 0 0.55rem;
  color: var(--accent-strong);
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.project-card h3 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.012em;
}

.project-card p:not(.project-kicker) {
  margin: 0.65rem 0 0;
  color: var(--text-muted);
  font-size: 0.94rem;
  line-height: 1.6;
}

.project-meta {
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1rem;
}

.project-meta li {
  padding: 0.22rem 0.48rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 650;
}

.project-arrow {
  display: inline-block;
  margin-top: 1.15rem;
  color: var(--accent-strong);
  font-size: 0.88rem;
  font-weight: 700;
}

.contact-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: clamp(1.4rem, 4vw, 2rem);
  border: 1px solid rgba(216, 165, 116, 0.5);
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.contact-panel h2 { margin-bottom: 0.5rem; }
.contact-panel p { margin: 0; color: var(--text-muted); }

.playground {
  margin-top: 2rem;
  padding: clamp(1.1rem, 3vw, 1.5rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.playground:focus-visible { outline-offset: 5px; }
.game-header h3 { margin: 0; font-size: 1.12rem; }

.game-instructions {
  margin: 0.45rem 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(180px, 1fr);
  gap: 1.4rem;
  align-items: start;
}

#gameCanvas {
  display: block;
  width: 100%;
  max-width: 360px;
  height: auto;
  aspect-ratio: 1;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #070708;
  image-rendering: pixelated;
  touch-action: pan-y;
}

.game-sidebar {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1rem;
}

.scoreboard {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.25rem;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.scoreboard div { display: flex; align-items: baseline; gap: 0.4rem; }
.scoreboard dt, .scoreboard dd { margin: 0; }

.scoreboard output {
  color: var(--text);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.game-status {
  min-height: 3.2em;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.game-buttons { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.game-buttons .button { flex: 1 1 78px; }

.direction-controls {
  display: none;
  width: min(100%, 210px);
  grid-template-columns: repeat(3, 1fr);
  grid-template-areas: ". up ." "left down right";
  gap: 0.45rem;
}

.direction-button {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-weight: 750;
}

.direction-button:hover, .direction-button:active { background: var(--surface-hover); }
.direction-button[data-direction="up"] { grid-area: up; }
.direction-button[data-direction="down"] { grid-area: down; }
.direction-button[data-direction="left"] { grid-area: left; }
.direction-button[data-direction="right"] { grid-area: right; }

.game-note { margin: 0; color: var(--text-dim); font-size: 0.82rem; }

.article-page { padding-block: clamp(3.5rem, 9vw, 6rem); }

.article-header {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.article-header h1, .not-found h1 {
  margin: 0;
  font-size: clamp(2.2rem, 7vw, 3.35rem);
  font-weight: 680;
  letter-spacing: -0.04em;
  line-height: 1.08;
  text-wrap: balance;
}

.article-header .lead {
  max-width: 650px;
  margin: 1rem 0 0;
  color: var(--text-muted);
  font-size: 1.08rem;
}

.article-meta { margin: 0.8rem 0 0; color: var(--text-dim); font-size: 0.9rem; }
.prose { max-width: 680px; }

.prose h2 {
  margin: 2.5rem 0 0.8rem;
  color: var(--text);
  font-size: 1.25rem;
  letter-spacing: -0.015em;
}

.prose p, .prose li { color: var(--text-muted); font-size: 1.01rem; }
.prose p { margin: 0 0 1rem; }
.prose ul { margin: 0 0 1rem; padding-left: 1.25rem; }
.prose li + li { margin-top: 0.45rem; }

.prose code {
  padding: 0.1em 0.32em;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9em;
}

.not-found { min-height: 65vh; padding-block: clamp(5rem, 14vw, 9rem); }
.not-found p:not(.eyebrow) { max-width: 560px; margin: 1rem 0 1.75rem; color: var(--text-muted); }

.site-footer {
  padding-block: 2.4rem 3rem;
  color: var(--text-dim);
  font-size: 0.86rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-footer p { margin: 0; }
.footer-links { flex-wrap: wrap; gap: 0.25rem; }

.footer-links a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 0.4rem 0.6rem;
  border-radius: 5px;
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover, .footer-links a[aria-current="page"] { color: var(--text); }

@media (max-width: 700px) {
  :root { --nav-height: 64px; }
  .container { width: min(100% - 2rem, var(--max-width)); }
  .projects { grid-template-columns: 1fr; }
  .project-card.is-featured { grid-column: auto; }
  .contact-panel { align-items: flex-start; flex-direction: column; }
  .game-layout { grid-template-columns: 1fr; }
  #gameCanvas { margin-inline: auto; }
  .direction-controls { display: grid; }
}

@media (max-width: 420px) {
  .brand-full { display: none; }
  .brand-short { display: inline; }
  .nav-inner { gap: 0.35rem; }
  .site-nav ul a { padding-inline: 0.48rem; font-size: 0.86rem; }
  .hero-actions .button { flex: 1 1 100%; }
  .project-card:not(.is-link), .project-card-link, .playground { padding: 1.05rem; }
  .project-card.is-link { padding: 0; }
  .game-buttons .button { flex-basis: calc(50% - 0.55rem); }
}

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

@media print {
  .site-nav, .site-footer, .skip-link, .hero-actions, .game-buttons, .direction-controls { display: none; }
  body { background: #fff; color: #111; }
  .container { width: 100%; max-width: none; }
}
