/* Self-hosted fonts (OFL), from Fontsource */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque.woff2") format("woff2-variations"), url("fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800; font-stretch: 75% 100%; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url("fonts/hanken-grotesk.woff2") format("woff2-variations"), url("fonts/hanken-grotesk.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Martian Mono";
  src: url("fonts/martian-mono.woff2") format("woff2-variations"), url("fonts/martian-mono.woff2") format("woff2");
  font-weight: 100 800; font-style: normal; font-display: swap;
}

/* Base (supplied by the preview host, needed standalone) */
:root { color-scheme: light; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* Layout: one quiet screen. A 3D scene (dot-grid pegboard, voxel wordmark, self-playing breakout) fills the
   background; a giant wordmark and two actions sit on top. The key opens as a sheet. */
:root {
  --bg: #e8edf4;
  --surface: #f5f8fc;
  --ink: #0c1628;
  --muted: #556178;
  --line: #c5cfdd;
  --accent: #1d4ed8;
  --accent-ink: #f4f7ff;
  --scrim: rgba(12, 22, 40, .32);
  --bg-hi: #f4f7fc;

  --f-display: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --f-body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "Martian Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --step--1: .78rem;
  --step-0: 1rem;
  --step-1: 1.2rem;
  --step-2: 1.6rem;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #08101f; --surface: #0f1a2e; --ink: #e2e9f5; --muted: #8592ab;
    --line: #1f2c46; --accent: #5b8cff; --accent-ink: #061024; --scrim: rgba(0, 0, 0, .55); --bg-hi: #10203f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #08101f; --surface: #0f1a2e; --ink: #e2e9f5; --muted: #8592ab;
  --line: #1f2c46; --accent: #5b8cff; --accent-ink: #061024; --scrim: rgba(0, 0, 0, .55); --bg-hi: #10203f;
  color-scheme: dark;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  background-image: radial-gradient(120% 85% at 45% 38%, var(--bg-hi), var(--bg) 70%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--step-0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: var(--accent); color: var(--accent-ink); }

.page {
  position: relative;
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 2rem;
  padding-block: clamp(20px, 4vh, 40px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  max-width: 1280px;
  margin: 0 auto;
  box-sizing: border-box;
}
@media (min-width: 720px) {
  .page {
    padding-left: max(40px, env(safe-area-inset-left, 0px));
    padding-right: max(40px, env(safe-area-inset-right, 0px));
  }
}

.mono {
  font-family: var(--f-mono);
  font-size: var(--step--1);
  letter-spacing: .04em;
  font-weight: 400;
}

.top, .foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  color: var(--muted);
}
.top { justify-content: flex-end; }
.top .dot {
  display: inline-block; width: .45em; height: .45em; border-radius: 50%;
  background: var(--accent); margin: 0 .3em; vertical-align: baseline;
  box-shadow: 0 0 0 0 var(--accent);
  animation: pulse 3.2s var(--ease) infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 .8em transparent; }
}

.hero {
  align-self: center;
  display: grid;
  gap: clamp(1.5rem, 4vh, 2.5rem);
  min-width: 0;
}

.wordmark {
  font-family: var(--f-display);
  font-variation-settings: "opsz" 96;
  font-weight: 800;
  font-size: clamp(4.2rem, 19vw, 15.5rem);
  line-height: .82;
  letter-spacing: -.055em;
  margin: 0;
  margin-left: -.05em;
  display: flex;
  overflow: hidden;
  padding-bottom: .08em;
}
.wordmark span {
  display: inline-block;
  animation: rise 1.1s var(--ease) both;
  animation-delay: calc(var(--i) * 55ms + 120ms);
}
.wordmark .tld { color: var(--accent); }
@keyframes rise {
  from { transform: translateY(105%); }
  to { transform: translateY(0); }
}

.lede {
  font-family: var(--f-display);
  font-variation-settings: "opsz" 24;
  font-weight: 400;
  font-size: var(--step-2);
  line-height: 1.2;
  letter-spacing: -.015em;
  margin: 0;
  max-width: 22ch;
  text-wrap: balance;
  animation: fade 1s var(--ease) .55s both;
}
.lede em { font-style: normal; color: var(--muted); }

@keyframes fade { from { transform: translateY(.6rem); opacity: .001; } to { transform: none; opacity: 1; } }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: stretch;
  animation: fade 1s var(--ease) .7s both;
}

.btn {
  --h: 3.6rem;
  appearance: none;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink);
  min-height: var(--h);
  padding: 0 1.4rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: .85rem;
  font: 500 var(--step-0)/1 var(--f-body);
  text-decoration: none;
  cursor: pointer;
  transition: transform .35s var(--ease), background .35s var(--ease), border-color .35s var(--ease), color .35s var(--ease);
  min-width: 0;
}
.btn:hover { transform: translateY(-2px); border-color: var(--ink); }
.btn:active { transform: translateY(0); }
.btn:focus-visible, .icon-btn:focus-visible, .sheet button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.mail {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
  padding-right: .5rem;
}
.mail:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.mail .label { display: grid; line-height: 1.15; gap: .2rem; }
.mail .label small {
  font: 400 .66rem/1 var(--f-mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .65;
}
.mail .addr { font-weight: 600; letter-spacing: -.005em; overflow-wrap: anywhere; }
.mail .arrow {
  width: 2.6rem; height: 2.6rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg); color: var(--ink);
  transition: transform .45s var(--ease), background .35s var(--ease), color .35s var(--ease);
  flex: none;
}
.mail:hover .arrow { transform: rotate(-45deg); background: var(--accent-ink); color: var(--accent); }

.key-btn .glyph { color: var(--accent); flex: none; }
.key-btn .kid { color: var(--muted); font-family: var(--f-mono); font-size: .72rem; letter-spacing: .04em; }

.icon-btn {
  appearance: none;
  width: 3.6rem; min-height: 3.6rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink);
  display: grid; place-items: center;
  cursor: pointer;
  transition: border-color .3s var(--ease), color .3s var(--ease);
}
.icon-btn:hover { border-color: var(--ink); }
.icon-btn.done { color: var(--accent); border-color: var(--accent); }

.foot { align-items: end; }
.fp-line { display: grid; gap: .35rem; min-width: 0; }
.fp-line .k { font-size: .64rem; letter-spacing: .14em; text-transform: uppercase; opacity: .8; }
.fp-line .v { color: var(--ink); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.fp-line .v b { font-weight: 500; color: var(--accent); }

/* Key sheet */
.scrim {
  position: fixed; inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 20;
  animation: scrim .35s var(--ease) both;
}
@keyframes scrim { from { opacity: 0; } }

.sheet {
  position: fixed;
  z-index: 21;
  top: max(12px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  width: min(560px, calc(100% - 24px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .35);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  animation: slide .5s var(--ease) both;
}
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
@media (max-width: 640px) {
  .sheet {
    top: auto;
    left: max(8px, env(safe-area-inset-left, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    bottom: max(8px, env(safe-area-inset-bottom, 0px));
    width: auto;
    max-height: 88%;
    animation-name: lift;
  }
  @keyframes lift { from { transform: translateY(40px); opacity: 0; } }
}

.sheet header {
  display: flex; justify-content: space-between; align-items: start; gap: 1rem;
  padding: 1.4rem 1.4rem 1rem;
  border-bottom: 1px solid var(--line);
}
.sheet h2 {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: var(--step-2);
  letter-spacing: -.02em;
  line-height: 1.1;
  margin: 0 0 .3rem;
}
.sheet header p { margin: 0; color: var(--muted); font-size: .92rem; }
.close {
  appearance: none; border: 1px solid var(--line); background: transparent; color: var(--ink);
  width: 2.4rem; height: 2.4rem; border-radius: 50%; display: grid; place-items: center; cursor: pointer; flex: none;
}
.close:hover { border-color: var(--ink); }

.sheet .body {
  overflow-y: auto;
  padding: 1.25rem 1.4rem;
  display: grid;
  gap: 1.25rem;
  align-content: start;
  min-height: 0;
}

.fp-big {
  display: grid;
  grid-template-columns: repeat(5, auto);
  justify-content: start;
  gap: .3rem 1rem;
  font-family: var(--f-mono);
  font-size: clamp(.82rem, 2.6vw, 1.02rem);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: .03em;
}
.fp-big span:nth-child(n+9) { color: var(--accent); font-weight: 500; }

.meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .45rem 1.25rem;
  margin: 0;
  font-size: .92rem;
}
.meta dt { color: var(--muted); font-family: var(--f-mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; padding-top: .2em; }
.meta dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.label-sm { font-family: var(--f-mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 .5rem; }

pre.armor {
  margin: 0;
  font-family: var(--f-mono);
  font-size: .7rem;
  line-height: 1.7;
  font-weight: 300;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  overflow-x: hidden;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: anywhere;
  color: var(--ink);
  user-select: all;
  -webkit-user-select: all;
}

.sheet footer {
  display: flex; flex-wrap: wrap; gap: .6rem;
  padding: 1rem 1.4rem calc(1rem + env(safe-area-inset-bottom, 0px) * 0);
  border-top: 1px solid var(--line);
}
.sheet footer button {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: .7rem 1.1rem;
  font: 500 .92rem/1 var(--f-body);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: .5rem;
  transition: background .3s var(--ease), color .3s var(--ease), border-color .3s var(--ease);
}
.sheet footer button.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.sheet footer button:hover { border-color: var(--accent); }
.sheet footer button.primary:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  font: 500 .88rem/1 var(--f-body);
  padding: .8rem 1.1rem;
  border-radius: 999px;
  z-index: 40;
  animation: toast .3s var(--ease) both;
}
@keyframes toast { from { transform: translate(-50%, 10px); opacity: 0; } }

@media (max-width: 520px) {
  .actions { flex-direction: column; align-items: stretch; }
  .mail-row { display: flex; gap: .6rem; }
  .mail-row .mail { flex: 1; justify-content: space-between; }
  .btn { justify-content: space-between; }
}
.mail-row { display: inline-flex; gap: .6rem; min-width: 0; }

/* Wide screens: wordmark and line on the left, actions stacked in a right-hand column
   so the play area under the wordmark stays clear. */
@media (min-width: 960px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) 21rem;
    column-gap: clamp(2rem, 5vw, 5rem);
    align-items: end;
  }
  .wordmark { font-size: clamp(4.2rem, 13.2vw, 13.5rem); grid-column: 1; grid-row: 1; }
  .actions {
    grid-column: 2; grid-row: 1;
    align-self: center;
    flex-direction: column;
    flex-wrap: nowrap;
  }
  .actions .mail-row { display: flex; }
  .actions .mail { flex: 1; justify-content: space-between; }
  .actions .mail .addr { white-space: nowrap; }
  .actions .key-btn { justify-content: space-between; }
}

/* 3D board: voxel wordmark + self-playing breakout, drawn behind the page content */
#board {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  pointer-events: none;
}
.is-3d .wordmark, .is-3d .wordmark .tld { color: transparent; }
.is-3d .wordmark span { animation: none; }

.game-hint {
  display: inline-flex; flex-wrap: wrap; gap: .3rem .7rem; align-items: baseline;
  animation: fade .8s var(--ease) both;
}
.game-hint b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.game-hint .sep { opacity: .5; }
.game-hint .power { display: inline-block; color: var(--accent); font-weight: 500; }
.game-hint .power.pop { animation: pop .5s var(--ease); }
@keyframes pop { 0% { transform: scale(1.35); } 100% { transform: none; } }
.game-hint .touch, .game-hint .you { display: none; }
@media (pointer: coarse) {
  .game-hint .keys { display: none; }
  .game-hint .touch { display: inline; }
}
.game-hint.steering .keys, .game-hint.steering .touch { display: none; }
.game-hint.steering .you { display: inline; color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}

/* letter stagger for the text wordmark (replaces inline style attributes) */
.wordmark span:nth-child(1) { --i: 0; }
.wordmark span:nth-child(2) { --i: 1; }
.wordmark span:nth-child(3) { --i: 2; }
.wordmark span:nth-child(4) { --i: 3; }
.wordmark span:nth-child(5) { --i: 4; }
.wordmark span:nth-child(6) { --i: 5; }
.wordmark span:nth-child(7) { --i: 6; }
.wordmark span:nth-child(8) { --i: 7; }
.sheet footer .dl { margin-left: auto; align-self: center; color: var(--accent); font: 500 .92rem/1 var(--f-body); text-underline-offset: .25em; }
