:root {
  color-scheme: light;
  --ink: #16232d;
  --muted: #5f7180;
  --line: #c9d6df;
  --paper: #f7fafc;
  --surface: #ffffff;
  --blue: #29485a;
  --soft-blue: #d9e6ee;
  --accent: #1fc9b5;
  --accent-dark: #0b7f75;
  --max: 1160px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eaf2f7;
  --muted: #9db0bf;
  --line: #334a59;
  --paper: #0d151b;
  --surface: #15222b;
  --blue: #9fc6dc;
  --soft-blue: #1b2d38;
  --accent: #56f1df;
  --accent-dark: #72f4e6;
}

* {
  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:
    linear-gradient(90deg, rgba(201, 214, 223, 0.45) 1px, transparent 1px),
    linear-gradient(rgba(201, 214, 223, 0.38) 1px, transparent 1px),
    var(--paper);
  background-size: 44px 44px;
  color: var(--ink);
}

:root[data-theme="dark"] body {
  background:
    linear-gradient(90deg, rgba(51, 74, 89, 0.45) 1px, transparent 1px),
    linear-gradient(rgba(51, 74, 89, 0.38) 1px, transparent 1px),
    var(--paper);
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100% - 32px, var(--max));
  margin: 0 auto;
  padding: 18px 0;
  backdrop-filter: blur(18px);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
}

.brand-logo {
  display: block;
  width: 42px;
  height: auto;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.site-nav a {
  padding: 10px 14px;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 0.95rem;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  border-color: var(--line);
  color: var(--ink);
  outline: none;
}

.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 1px;
  margin: 5px auto;
  background: var(--ink);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink);
  padding: 0 10px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  user-select: none;
}

.theme-toggle__track {
  position: relative;
  width: 38px;
  height: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
}

:root[data-theme="dark"] .theme-toggle {
  background: rgba(21, 34, 43, 0.72);
}

.theme-toggle__track span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  background: var(--accent-dark);
  transition: transform 180ms ease;
}

.theme-toggle[aria-checked="true"] .theme-toggle__track span {
  transform: translateX(20px);
}

.theme-toggle__text {
  min-width: 34px;
  font-size: 0.86rem;
}

main {
  width: min(100% - 32px, var(--max));
  margin: 0 auto;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.03fr) minmax(320px, 0.97fr);
  gap: 34px;
  align-items: center;
  min-height: calc(100vh - 76px);
  padding: 36px 0 72px;
}

.hero-copy h1,
.page-hero h1,
.about-copy h1,
.contact-layout h1 {
  max-width: 840px;
  margin: 0;
  font-size: 6.4rem;
  line-height: 0.94;
  letter-spacing: 0;
}

.hero-lead,
.page-hero p,
.about-copy > p,
.contact-layout > div > p,
.line-section p {
  max-width: 660px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.8;
}

.eyebrow {
  display: none;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  font-weight: 750;
}

.button.primary {
  background: var(--ink);
  color: white;
}

:root[data-theme="dark"] .button.primary {
  background: #f7fafc;
  border-color: #f7fafc;
  color: #0d151b;
}

.button.secondary {
  background: rgba(255, 255, 255, 0.62);
}

:root[data-theme="dark"] .button.secondary {
  background: rgba(21, 34, 43, 0.7);
}

.dice-stage {
  position: relative;
  min-height: 540px;
  border: 10px solid #142a35;
  border-radius: 18px;
  background: #061014;
  box-shadow:
    0 24px 60px rgba(3, 12, 16, 0.26),
    inset 0 0 0 1px rgba(247, 250, 252, 0.08),
    inset 0 0 46px rgba(3, 12, 16, 0.72);
  overflow: hidden;
}

.dice-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 1px rgba(129, 230, 217, 0.16),
    inset 0 0 36px rgba(129, 230, 217, 0.1),
    inset 0 0 110px rgba(0, 0, 0, 0.48);
}

:root[data-theme="dark"] .dice-stage {
  border-color: #213845;
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(247, 250, 252, 0.1),
    inset 0 0 54px rgba(0, 0, 0, 0.78);
}

#d20-canvas {
  display: block;
  width: 100%;
  height: 100%;
  filter: saturate(1.08) contrast(1.08);
}

.crt-overlay {
  position: absolute;
  inset: 4px;
  pointer-events: none;
  z-index: 1;
  border-radius: 10px;
  background:
    radial-gradient(ellipse at center, transparent 42%, rgba(3, 12, 16, 0.18) 72%, rgba(3, 12, 16, 0.46) 100%),
    linear-gradient(rgba(255, 255, 255, 0.035) 50%, rgba(0, 0, 0, 0.16) 50%),
    linear-gradient(90deg, rgba(31, 201, 181, 0.08), rgba(255, 255, 255, 0.015), rgba(65, 133, 167, 0.08));
  background-size: 100% 100%, 100% 4px, 6px 100%;
  box-shadow:
    inset 0 0 64px rgba(129, 230, 217, 0.13),
    inset 0 0 140px rgba(3, 12, 16, 0.48);
  mix-blend-mode: screen;
  opacity: 0.74;
  animation: crt-flicker 3.8s infinite steps(2, end);
}

.crt-overlay::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(129, 230, 217, 0.16);
  transform: scaleX(1.015);
  border-radius: 50% / 7%;
  box-shadow: inset 0 0 28px rgba(129, 230, 217, 0.12);
}

.crt-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(129, 230, 217, 0.12), transparent);
  height: 38%;
  opacity: 0.24;
  transform: translateY(-120%);
  animation: crt-scan 7s linear infinite;
}

@keyframes crt-flicker {
  0%,
  100% {
    opacity: 0.68;
  }
  48% {
    opacity: 0.78;
  }
  52% {
    opacity: 0.62;
  }
}

@keyframes crt-scan {
  0% {
    transform: translateY(-130%);
  }
  100% {
    transform: translateY(280%);
  }
}

.line-section {
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--line);
  padding: 64px 0;
}

.split {
  display: grid;
  grid-template-columns: 0.85fr 1fr;
  gap: 48px;
}

.line-section h2,
.section-heading h2 {
  margin: 0;
  font-size: 4.1rem;
  line-height: 1;
}

.services-grid,
.work-grid,
.process-strip {
  display: grid;
  gap: 1px;
  margin: 44px 0 84px;
  background: var(--line);
  border: 1px solid var(--line);
}

.services-grid,
.process-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.service-card,
.project-card,
.process-strip article {
  min-height: 260px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.78);
}

:root[data-theme="dark"] .service-card,
:root[data-theme="dark"] .project-card,
:root[data-theme="dark"] .process-strip article,
:root[data-theme="dark"] .fact-list div,
:root[data-theme="dark"] .contact-lines a,
:root[data-theme="dark"] .contact-form,
:root[data-theme="dark"] .system-line {
  background: rgba(21, 34, 43, 0.78);
}

.service-card span,
.process-strip span,
.project-topline {
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.service-card h3,
.project-card h3,
.process-strip h2 {
  margin: 38px 0 16px;
  font-size: 1.55rem;
  line-height: 1.1;
}

.service-card p,
.project-card p,
.process-strip p {
  color: var(--muted);
  line-height: 1.7;
}

.featured-work,
.page-hero {
  padding: 64px 0 20px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  border-top: 1px solid var(--ink);
  padding-top: 34px;
}

.project-topline {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.page-hero {
  min-height: 48vh;
  display: grid;
  align-content: end;
  border-bottom: 1px solid var(--line);
}

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

.about-layout,
.contact-layout {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 56px;
  align-items: center;
  min-height: calc(100vh - 92px);
  padding: 54px 0 70px;
}

.system-line {
  position: relative;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.52);
  aspect-ratio: 5 / 6;
  overflow: hidden;
}

.system-line::before,
.system-line::after {
  content: "";
  position: absolute;
  inset: 16%;
  border: 1px solid var(--blue);
  transform: rotate(10deg);
}

.system-line::after {
  inset: 28%;
  border-color: var(--accent-dark);
  transform: rotate(-18deg);
}

.system-node {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 1px solid var(--ink);
  background: var(--paper);
}

.node-a {
  top: 18%;
  left: 24%;
}

.node-b {
  top: 42%;
  right: 17%;
}

.node-c {
  bottom: 19%;
  left: 35%;
}

.system-die {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border: 1px solid var(--ink);
  transform: translate(-50%, -50%);
  clip-path: polygon(50% 0, 96% 25%, 96% 75%, 50% 100%, 4% 75%, 4% 25%);
  color: var(--accent-dark);
  font-size: 1.35rem;
  font-weight: 850;
}

.fact-list {
  display: grid;
  gap: 1px;
  margin: 34px 0 0;
  background: var(--line);
  border: 1px solid var(--line);
}

.fact-list div {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 20px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.8);
}

.fact-list dt {
  color: var(--accent-dark);
  font-weight: 800;
}

.fact-list dd {
  margin: 0;
  color: var(--muted);
}

.contact-layout {
  align-items: start;
  padding-top: 88px;
}

.contact-lines {
  display: grid;
  gap: 1px;
  max-width: 520px;
  margin-top: 34px;
  background: var(--line);
  border: 1px solid var(--line);
}

.contact-lines a {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.8);
}

.contact-lines span {
  color: var(--muted);
}

.contact-form {
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
}

.contact-form label {
  display: grid;
  gap: 8px;
  color: var(--blue);
  font-weight: 750;
}

.contact-form input,
.contact-form textarea,
.contact-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 14px 12px;
  background: white;
  color: var(--ink);
  font: inherit;
}

:root[data-theme="dark"] .contact-form input,
:root[data-theme="dark"] .contact-form textarea,
:root[data-theme="dark"] .contact-form select {
  background: #101b22;
}

.contact-form input:focus,
.contact-form textarea:focus,
.contact-form select:focus {
  border-color: var(--accent-dark);
  outline: 3px solid rgba(31, 201, 181, 0.2);
}

.form-status {
  min-height: 24px;
  margin: 0;
  color: var(--accent-dark);
  font-weight: 700;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  width: min(100% - 32px, var(--max));
  margin: 0 auto;
  padding: 34px 0 42px;
  border-top: 1px solid var(--ink);
  color: var(--muted);
}

.site-footer div {
  display: flex;
  gap: 18px;
}

@media (max-width: 860px) {
  .nav-toggle {
    display: block;
  }

  .site-nav {
    position: absolute;
    top: 72px;
    right: 0;
    left: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    padding: 14px;
    border: 1px solid var(--line);
    background: rgba(247, 250, 252, 0.96);
  }

  .site-nav.is-open {
    display: flex;
  }

  .theme-toggle {
    margin-left: auto;
  }

  .hero-grid,
  .split,
  .about-layout,
  .contact-layout {
    grid-template-columns: 1fr;
  }

  .hero-copy h1,
  .page-hero h1,
  .about-copy h1,
  .contact-layout h1 {
    font-size: 4.4rem;
  }

  .dice-stage {
    min-height: 390px;
    border-width: 8px;
  }

  .services-grid,
  .work-grid,
  .process-strip,
  .all-work {
    grid-template-columns: 1fr;
  }

  .section-heading,
  .site-footer,
  .site-footer div {
    align-items: start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  main,
  .site-header,
  .site-footer {
    width: min(100% - 22px, var(--max));
  }

  .brand-mark span:last-child {
    max-width: 150px;
    line-height: 1.1;
  }

  .hero-grid {
    padding-top: 22px;
  }

  .hero-copy h1,
  .page-hero h1,
  .about-copy h1,
  .contact-layout h1 {
    font-size: 3.05rem;
  }

  .line-section h2,
  .section-heading h2 {
    font-size: 2.35rem;
  }

  .hero-actions {
    flex-direction: column;
  }

  .button {
    width: 100%;
  }

  .fact-list div,
  .contact-lines a {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}
