:root {
  --paper: #efe6d8;
  --paper-2: #f7f1e8;
  --ink: #242421;
  --muted: #71695e;
  --graphite: #2d302d;
  --green: #71806b;
  --steel: #8b9696;
  --amber: #d9863d;
  --coffee: #6f4a33;
  --line: rgba(44, 40, 34, .16);
  --shadow: 0 22px 70px rgba(41, 33, 23, .16);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(36, 36, 33, .045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(36, 36, 33, .035) 1px, transparent 1px),
    var(--paper);
  background-size: 48px 48px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  opacity: .18;
  background-image: radial-gradient(rgba(30, 27, 23, .32) 1px, transparent 1px);
  background-size: 9px 9px;
  mix-blend-mode: multiply;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px clamp(18px, 4vw, 56px);
  background: rgba(239, 230, 216, .82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.brand {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 5px;
  background: rgba(247, 241, 232, .62);
  border: 1px solid var(--line);
}
.brand img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
nav { display: flex; gap: clamp(10px, 2vw, 26px); font-size: 13px; color: var(--muted); }
nav a:hover { color: var(--ink); }

.section-pad { padding: clamp(54px, 8vw, 112px) clamp(18px, 5vw, 72px); }
.hero {
  min-height: calc(100vh - 76px);
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(320px, 1.1fr);
  align-items: center;
  gap: clamp(28px, 5vw, 74px);
}
.eyebrow, .section-marker {
  margin: 0 0 16px;
  color: var(--coffee);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(46px, 7vw, 92px);
  line-height: .98;
  letter-spacing: 0;
}
h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 54px);
  line-height: 1.02;
  letter-spacing: 0;
}
h3 { margin: 0 0 12px; font-size: 18px; line-height: 1.15; }
.tagline {
  max-width: 650px;
  margin: 24px 0 0;
  color: #33342f;
  font-size: clamp(20px, 2.4vw, 31px);
  line-height: 1.18;
}
.body-copy {
  max-width: 620px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.button {
  border: 1px solid var(--line);
  padding: 12px 16px;
  min-height: 44px;
  background: rgba(255,255,255,.32);
  color: var(--ink);
  cursor: pointer;
}
.button.primary { background: var(--ink); color: var(--paper-2); }
.button:hover { transform: translateY(-2px); }

.hero-media {
  position: relative;
  min-height: min(62vh, 560px);
  overflow: hidden;
  background: var(--graphite);
  border: 1px solid rgba(36,36,33,.22);
  box-shadow: var(--shadow);
}
.media-slide {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: scale(1.03);
  transition: opacity .8s ease, transform 1.4s ease;
}
.media-slide.active { opacity: 1; transform: scale(1); }
.media-slide img, .media-slide video { width: 100%; height: 100%; object-fit: cover; }
.signals { padding-top: 20px; }
.signals,
.content-section,
.contact,
.hero {
  width: min(1440px, calc(100% - 32px));
  margin-left: auto;
  margin-right: auto;
}
.signal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.signal-card, .content-module, .gallery-item, .contact-card {
  border: 1px solid var(--line);
  background: rgba(247, 241, 232, .74);
  box-shadow: 0 12px 36px rgba(45, 38, 29, .07);
}
.signal-card {
  min-height: 210px;
  padding: 18px;
  transition: transform .25s ease, background .25s ease;
}
.signal-card:hover, .gallery-item:hover { transform: translateY(-4px); background: rgba(255,255,255,.54); }
.technical-label {
  display: inline-flex;
  margin-bottom: 18px;
  padding: 6px 8px;
  color: var(--green);
  border: 1px solid rgba(113,128,107,.32);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.signal-card p, .content-module p { color: var(--muted); line-height: 1.65; }

.content-section {
  border-top: 1px solid var(--line);
}
.content-module {
  width: 100%;
  padding: clamp(24px, 4vw, 46px) 0;
  background: transparent;
  border-left: 0;
  border-right: 0;
  box-shadow: none;
}
.content-module > h2,
.content-module > p {
  max-width: 920px;
}
.section-media-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 28px;
}
.section-carousel {
  position: relative;
  margin-top: 30px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.24);
  overflow: hidden;
}
.carousel-track {
  position: relative;
  min-height: clamp(280px, 42vw, 520px);
}
.carousel-slide {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  transform: translateX(18px);
  transition: opacity .35s ease, transform .35s ease;
  pointer-events: none;
}
.carousel-slide.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.carousel-slide > div {
  position: relative;
  height: 100%;
}
.carousel-slide img,
.carousel-slide video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.carousel-btn {
  position: absolute;
  top: 50%;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 42px;
  height: 58px;
  border: 1px solid rgba(255,255,255,.25);
  color: var(--paper-2);
  background: rgba(36, 36, 33, .72);
  transform: translateY(-50%);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
}
.carousel-btn.prev { left: 10px; }
.carousel-btn.next { right: 10px; }
.carousel-dots {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 3;
  display: flex;
  gap: 7px;
  transform: translateX(-50%);
}
.carousel-dots button {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.72);
  background: rgba(36,36,33,.46);
  cursor: pointer;
}
.carousel-dots button.active {
  width: 22px;
  background: var(--amber);
}
.visuals-band {
  width: 100%;
  margin-top: 30px;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.22);
}
.visuals-track {
  display: flex;
  width: max-content;
  animation: visualsMarquee 42s linear infinite;
}
.visuals-band:hover .visuals-track {
  animation-play-state: paused;
}
.visuals-item {
  flex: 0 0 auto;
  width: clamp(220px, 26vw, 380px);
  aspect-ratio: 1;
  margin: 0;
  overflow: hidden;
  transition: transform .25s ease;
}
.visuals-item:hover {
  position: relative;
  z-index: 2;
  transform: scale(1.18);
}
.visuals-item > div,
.visuals-item img,
.visuals-item video {
  width: 100%;
  height: 100%;
}
.visuals-item img,
.visuals-item video {
  display: block;
  object-fit: cover;
}
@keyframes visualsMarquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
.section-media-item {
  min-height: 170px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.28);
}
.section-media-item > div {
  position: relative;
  height: 100%;
}
.section-media-item img,
.section-media-item video {
  display: block;
  width: 100%;
  height: 190px;
  object-fit: cover;
}

.section-heading { max-width: 780px; margin-bottom: 26px; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.gallery-item { overflow: hidden; min-height: 260px; }
.gallery-item img, .gallery-item video { width: 100%; height: 230px; object-fit: cover; display: block; }
.gallery-item figcaption { padding: 12px; font-size: 13px; color: var(--muted); }

.contact { padding-bottom: 130px; }
.contact-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(360px, 1.1fr);
  gap: clamp(22px, 5vw, 70px);
  width: 100%;
  padding: clamp(28px, 5vw, 58px);
  overflow: hidden;
}
.contact-card::before {
  content: "SEND SIGNAL";
  position: absolute;
  right: clamp(18px, 4vw, 48px);
  top: clamp(18px, 4vw, 44px);
  color: rgba(217, 134, 61, .22);
  font-size: clamp(38px, 8vw, 128px);
  font-weight: 900;
  line-height: .8;
  pointer-events: none;
}
.contact-card > .eyebrow,
.contact-card > h2,
.contact-card > p,
.contact-console {
  grid-column: 1;
  position: relative;
  z-index: 1;
}
.contact-console {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: end;
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed rgba(45, 38, 29, .2);
  background:
    linear-gradient(90deg, rgba(113,128,107,.14) 1px, transparent 1px),
    linear-gradient(0deg, rgba(113,128,107,.1) 1px, transparent 1px),
    rgba(255,255,255,.24);
  background-size: 18px 18px;
}
.console-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  color: var(--graphite);
  background: rgba(247, 241, 232, .82);
  border: 1px solid rgba(45, 38, 29, .12);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}
.console-light {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(217, 134, 61, .16), 0 0 14px rgba(217, 134, 61, .75);
}
.console-cursor {
  width: 9px;
  min-height: 26px;
  background: var(--green);
  animation: cursorBlink 1s steps(2, start) infinite;
}
.contact-links {
  position: relative;
  z-index: 1;
  grid-column: 2;
  grid-row: 1 / span 4;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: end;
}
.contact-action {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.36);
  transition: transform .22s ease, background .22s ease;
}
.contact-action:hover {
  transform: translateY(-4px) rotate(-1deg);
  background: rgba(217, 134, 61, .16);
}
.contact-action:nth-child(even):hover {
  transform: translateY(-4px) rotate(1deg);
}
.contact-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: var(--paper-2);
  background: var(--graphite);
  font-size: 13px;
  font-weight: 900;
}
.contact-action strong,
.contact-action small {
  display: block;
  overflow-wrap: anywhere;
}
.contact-action small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
@keyframes cursorBlink {
  50% { opacity: .2; }
}

.reveal { opacity: 0; transform: translateY(22px); transition: opacity .7s ease, transform .7s ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }

.pixel-companion {
  position: fixed;
  left: 24px;
  top: 64vh;
  z-index: 30;
  width: 36px;
  height: 69px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: transform .22s ease;
}
.pixel-companion.in-portal {
  opacity: 0;
  transform: scale(.25);
}
.pixel-companion.dragging { cursor: grabbing; transition: none; }
.pixel-sprite {
  position: absolute;
  inset: 0;
  image-rendering: pixelated;
  filter: drop-shadow(0 6px 0 rgba(36,36,33,.12));
  animation: idle 1.8s steps(2) infinite;
}
.pixel-companion.is-walking .pixel-sprite {
  animation: walkBob .34s steps(2) infinite;
}
.pixel-companion.is-sitting .pixel-sprite {
  animation: none;
  transform: translateY(11px);
}
.pixel-sprite img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.bubble {
  position: absolute;
  left: 28px;
  bottom: 60px;
  width: max-content;
  max-width: 112px;
  padding: 6px 8px;
  color: var(--paper-2);
  background: var(--graphite);
  font-size: 10px;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
}
.pixel-companion:hover .bubble { opacity: 1; transform: translateY(0); }
@keyframes idle { to { transform: translateY(-2px); } }
@keyframes walkBob { to { transform: translateY(-4px); } }

.portal-door {
  position: fixed;
  z-index: 44;
  width: 42px;
  height: 62px;
  transform: translateY(-100%) scaleX(.25);
  transform-origin: center bottom;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 0 12px rgba(217,134,61,.38));
}
.portal-door.open {
  animation: portalOpen .72s ease both;
}
.portal-door.left {
  transform-origin: left bottom;
}
.portal-door.right {
  transform-origin: right bottom;
}
@keyframes portalOpen {
  0% { opacity: 0; transform: translateY(-100%) scaleX(.12); }
  28%, 72% { opacity: 1; transform: translateY(-100%) scaleX(1); }
  100% { opacity: 0; transform: translateY(-100%) scaleX(.12); }
}

.hud {
  position: fixed;
  left: 50%;
  top: 86px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  color: var(--paper-2);
  background: var(--graphite);
  transform: translateX(-50%);
}
#hudTime {
  min-width: 150px;
  color: var(--amber);
  font-size: clamp(40px, 8vw, 96px);
  font-weight: 900;
  line-height: .85;
  text-align: center;
}
.hud button {
  border: 1px solid rgba(255,255,255,.25);
  color: var(--paper-2);
  background: transparent;
  cursor: pointer;
}
.falling-item {
  position: fixed;
  z-index: 35;
  width: 30px;
  height: 30px;
  object-fit: contain;
  pointer-events: none;
}
body.game-mode { cursor: crosshair; }
body.game-mode {
  overflow: hidden;
}
body.game-mode .pixel-companion {
  transition: none;
  z-index: 45;
}
.scoreboard {
  position: fixed;
  right: 18px;
  top: 178px;
  z-index: 38;
  width: min(240px, calc(100vw - 36px));
  padding: 12px;
  border: 1px solid rgba(255,255,255,.2);
  color: var(--paper-2);
  background: rgba(45, 48, 45, .88);
}
.scoreboard-title {
  margin: 0 0 8px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.scoreboard ol {
  margin: 0;
  padding-left: 20px;
  font-size: 12px;
  line-height: 1.6;
}
.game-over {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(36, 36, 33, .62);
  backdrop-filter: blur(10px);
}
.game-over-card {
  width: min(560px, 100%);
  padding: clamp(24px, 4vw, 42px);
  border: 1px solid var(--line);
  background: var(--paper-2);
  box-shadow: var(--shadow);
}
.game-over-card h2 { font-size: clamp(30px, 6vw, 56px); }
.game-over-card input {
  width: 100%;
  border: 1px solid var(--line);
  padding: 12px;
  background: rgba(255,255,255,.68);
}
.game-note, .status-line { color: var(--muted); font-size: 13px; }
.status-line { min-height: 18px; font-weight: 800; }

@media (max-width: 920px) {
  .hero { grid-template-columns: 1fr; }
  .hero { min-height: auto; }
  .hero-media { min-height: 430px; }
  .signal-grid, .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .contact-card { grid-template-columns: 1fr; }
  .contact-links { grid-column: 1; grid-row: auto; }
}

@media (max-width: 620px) {
  .topbar { align-items: flex-start; }
  nav { max-width: 230px; flex-wrap: wrap; justify-content: flex-end; }
  .section-pad { padding-left: 16px; padding-right: 16px; }
  .signal-grid, .gallery-grid { grid-template-columns: 1fr; }
  .section-media-grid { grid-template-columns: 1fr; }
  .carousel-track { min-height: 360px; }
  .carousel-btn { width: 36px; height: 48px; }
  .contact-links { grid-template-columns: 1fr; }
  .hero-media { min-height: 320px; }
  .pixel-companion { left: 8px; }
  .hud {
    top: 78px;
    width: calc(100vw - 24px);
    justify-content: space-between;
  }
  #hudTime {
    min-width: 112px;
    font-size: 44px;
  }
  .scoreboard {
    top: auto;
    right: 12px;
    bottom: 12px;
    width: 170px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; transition: none !important; }
}
