:root {
  --bg: #f5f2eb;
  --surface: #fffdf9;
  --surface-soft: #efe8dc;
  --text: #1f252b;
  --muted: #66717a;
  --line: #dad2c4;
  --accent: #496d68;
  --accent-strong: #35534f;
  --toast: #20252a;
  --toast-text: #f8fbfc;
  --shadow: 0 12px 32px rgba(29, 38, 46, 0.08);
  --radius: 18px;
  --max-width: 1080px;
}

:root[data-theme="dark"] {
  --bg: #16191c;
  --surface: #1e2328;
  --surface-soft: #272d33;
  --text: #eef2f4;
  --muted: #b3bcc6;
  --line: #363c43;
  --accent: #8db6b0;
  --accent-strong: #a6cac5;
  --toast: #f5f2eb;
  --toast-text: #1b2025;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.3);
}

:root[data-theme="deep-space"] {
  --bg: #090d16;
  --surface: rgba(15, 20, 35, 0.9);
  --surface-soft: rgba(29, 36, 60, 0.9);
  --text: #ebf2ff;
  --muted: #9eb2d3;
  --line: rgba(255, 255, 255, 0.09);
  --accent: #78b9ff;
  --accent-strong: #9f8dff;
  --toast: #e8f1ff;
  --toast-text: #0f1728;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  transition: background 200ms ease, color 200ms ease;
}

body.game-mode {
  background:
    repeating-linear-gradient(
      0deg,
      rgba(125, 255, 173, 0.08) 0,
      rgba(125, 255, 173, 0.08) 2px,
      transparent 2px,
      transparent 4px
    ),
    radial-gradient(circle at 50% 18%, rgba(125, 255, 173, 0.08), transparent 38%),
    #090f16;
  color: #d9ffe5;
  text-shadow: 0 0 1px rgba(125, 255, 173, 0.2);
}

body.retro-mode {
  image-rendering: pixelated;
  font-family: "Silkscreen", "Courier New", Courier, monospace;
  letter-spacing: 0.01em;
}

body.retro-mode * {
  border-radius: 0 !important;
  box-shadow: none !important;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

img {
  display: block;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

.container {
  width: min(calc(100% - 2rem), var(--max-width));
  margin: 0 auto;
}

.section {
  padding: 5rem 0;
}

.section-narrow {
  max-width: 820px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 76px;
}

.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.site-nav a {
  color: var(--muted);
  font-weight: 600;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.theme-toggle,
.nav-toggle,
.footer-stars,
.command-list button,
.terminal-close,
#command-close {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
}

.theme-toggle,
.nav-toggle {
  width: 42px;
  height: 42px;
}

.nav-toggle {
  display: none;
  position: relative;
  padding: 0;
}

.nav-toggle span {
  position: absolute;
  left: 10px;
  right: 10px;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
  transition: transform 160ms ease, opacity 160ms ease;
}

.nav-toggle span:nth-child(1) { top: 13px; }
.nav-toggle span:nth-child(2) { top: 20px; }
.nav-toggle span:nth-child(3) { top: 27px; }

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.hero {
  padding-top: 6rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1.5rem;
  align-items: start;
}

.eyebrow {
  display: inline-flex;
  margin: 0 0 1rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.94rem;
  font-weight: 600;
}

h1,
h2,
h3 {
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 0 0 1rem;
}

h1 {
  font-size: clamp(2.8rem, 7vw, 4.8rem);
}

h2 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

h3 {
  font-size: 1.15rem;
}

.lead,
.card p,
.section-head p,
.contact-link span:last-child,
.secret-project p,
#secret-fact-text {
  color: var(--muted);
}

.lead {
  margin: 0;
  max-width: 58ch;
  font-size: 1.1rem;
}

.hero-actions,
.project-content .btn {
  margin-top: 1.5rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0.85rem 1.1rem;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 700;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--accent-strong);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--line);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem;
  transition: transform 220ms ease;
}

body.game-mode .site-header,
body.game-mode .card,
body.game-mode .contact-link,
body.game-mode .site-nav.is-open,
body.game-mode .command-panel,
body.game-mode .secret-facts-card,
body.game-mode .retro-card,
body.game-mode .terminal-header,
body.game-mode .terminal-body,
body.game-mode .terminal-form {
  border-color: rgba(125, 255, 173, 0.4);
}

body.game-mode .site-header,
body.game-mode .card,
body.game-mode .contact-link,
body.game-mode .site-nav.is-open {
  background: rgba(9, 18, 24, 0.9);
}

body.game-mode .btn-primary {
  background: linear-gradient(90deg, #39ff88, #24d96f);
  color: #08120a;
}

body.game-mode .btn-secondary,
body.game-mode .theme-toggle,
body.game-mode .nav-toggle,
body.game-mode .footer-stars {
  background: rgba(13, 22, 28, 0.95);
}

body.game-mode .section-head h2::before {
  content: "> ";
  color: #7dffad;
}

body.game-mode h1::after {
  content: " // INSERT COIN";
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.28em;
  letter-spacing: 0.08em;
  color: #7dffad;
}

.hero-card h2 {
  font-size: 1.45rem;
}

.status-chip {
  display: inline-flex;
  margin-bottom: 1rem;
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.section-head {
  margin-bottom: 1.5rem;
}

.prose-card p + p {
  margin-top: 1rem;
}

.card-grid,
.project-grid {
  display: grid;
  gap: 1.25rem;
}

.card-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.project-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.project-card {
  overflow: hidden;
  position: relative;
}

.project-image {
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 1rem;
  background: var(--surface-soft);
}

.tag-list,
.skill-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.tag-list li,
.skill-list li {
  padding: 0.45rem 0.72rem;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.92rem;
}

.contact-links {
  display: grid;
  gap: 0.8rem;
}

.contact-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  font-weight: 600;
}

.site-footer {
  padding: 0 0 2.5rem;
  color: var(--muted);
}

.footer-inner {
  border-top: 1px solid var(--line);
  padding-top: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.footer-stars {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.4rem 0.55rem;
}

.footer-stars span {
  display: inline-block;
  transition: transform 160ms ease, color 160ms ease;
}

.footer-stars span.active {
  color: var(--accent);
  transform: scale(1.18);
}

.toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
  display: grid;
  gap: 0.65rem;
}

.toast {
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: var(--toast);
  color: var(--toast-text);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-width: 220px;
  animation: rise 220ms ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.terminal,
.command-palette,
.secret-facts,
.retro-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(10, 12, 16, 0.45);
  backdrop-filter: blur(8px);
}

.terminal {
  align-items: end;
  justify-items: end;
  background: transparent;
  pointer-events: none;
}

.terminal:not(.hidden) {
  pointer-events: auto;
}

.terminal > * {
  pointer-events: auto;
}

.terminal {
  padding: 1rem;
}

.terminal-header,
.command-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.terminal {
  place-items: end;
}

.terminal-body,
.terminal-form,
.command-panel,
.secret-facts-card,
.retro-card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.terminal-body,
.terminal-form {
  background: #0d1117;
  color: #d8f7dd;
  border-color: #243242;
}

.terminal {
  grid-template-rows: auto;
}

#terminal {
  width: min(540px, calc(100% - 2rem));
  overflow: hidden;
  border-radius: 16px;
  isolation: isolate;
}

#terminal .terminal-header {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 0.85rem 1rem;
  background: #111827;
  color: #eef2f4;
  border: 1px solid #243242;
  border-bottom: none;
  border-radius: 16px 16px 0 0;
}

#terminal .terminal-body {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 230px;
  padding: 1rem;
  overflow: auto;
}

#terminal .terminal-form {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.9rem 1rem;
  border-top: 1px solid #243242;
  border-radius: 0 0 16px 16px;
}

#terminal input {
  flex: 1;
  background: transparent;
  color: inherit;
  border: none;
  outline: none;
}

.terminal-prompt {
  color: #8ad3a7;
}

.command-panel,
.secret-facts-card,
.retro-card {
  width: min(460px, 100%);
  border-radius: 18px;
  padding: 1.2rem;
}

.command-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.command-list button,
#command-close,
.terminal-close {
  padding: 0.75rem 0.9rem;
}

.command-list button {
  text-align: left;
}

.secret-project {
  margin-top: 1.25rem;
}

.secret-project-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.secret-project-head h3 {
  margin: 0;
}

.secret-project-close {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  border-radius: 10px;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.secret-project-close:hover,
.secret-project-close:focus-visible {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.retro-card,
.secret-facts-card {
  text-align: center;
}

@media (max-width: 900px) {
  .hero-grid,
  .card-grid,
  .project-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .site-nav {
    position: absolute;
    top: calc(100% + 0.6rem);
    left: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.9rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 160ms ease, transform 160ms ease;
  }

  .site-nav.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .nav-toggle {
    display: inline-flex;
  }

  .hero {
    padding-top: 4.5rem;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}