:root {
  --s: 4px;          /* one scene pixel on screen, set by main.js */
  --k: 2;            /* title font multiplier, set by main.js */
  --ui: 16px;        /* prompt font size */
  --ui-sm: 8px;      /* sound toggle font size */
  --txt: 16px;       /* dialog text size */
  --b: 2px;          /* pixel border width */
  --o: 2px;          /* text outline width */
  --ink: #04030c;
  --text: #ffffff;
  --cyan: #9ff4ff;
  --gold-hi: #fff0a8;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--text);
  font-family: 'Press Start 2P', ui-monospace, monospace;
  -webkit-font-smoothing: none;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

canvas {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  touch-action: manipulation;
}

button { font-family: inherit; }

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

/* ---------- dialog boxes (Zelda style) ---------- */
.dialog {
  position: relative;
  padding: calc(var(--txt) * 1.1) calc(var(--txt) * 1.3);
  font-size: var(--txt);
  line-height: 2;
  text-align: left;
  overflow-wrap: anywhere;
  min-width: 0;
  color: var(--text);
  background: #05040f;
  border: var(--b) solid #f4f1e6;
  box-shadow:
    inset 0 0 0 var(--b) #05040f,
    inset 0 0 0 calc(var(--b) * 2) #3a3f7a,
    0 0 0 var(--b) #05040f,
    var(--b) calc(var(--b) * 2) 0 var(--b) rgba(0, 0, 0, 0.45);
}
.dialog p { margin: 0; }
.ghost { visibility: hidden; }

.welcome {
  position: fixed;
  top: calc(var(--s) * 6);
  left: 16px;
  right: 16px;
  margin: 0 auto;
  max-width: 40em;
  cursor: pointer;
}
.welcome.is-gone { display: none; }
.next {
  position: absolute;
  right: 1em;
  bottom: 0.6em;
  width: 0.7em;
  height: 0.45em;
  background: #fff;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  opacity: 0;
}
.welcome.is-typed .next { opacity: 1; animation: blink 0.8s steps(1, end) infinite; }

/* ---------- idle prompt ---------- */
.prompt {
  position: fixed;
  left: 50%;
  top: 85vh;
  transform: translate(-50%, -50%);
  padding: 0.6em;
  border: 0;
  background: none;
  color: var(--text);
  font-size: var(--ui);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-shadow: var(--o) 0 0 var(--ink), calc(var(--o) * -1) 0 0 var(--ink), 0 var(--o) 0 var(--ink), 0 calc(var(--o) * -1) 0 var(--ink), var(--o) var(--o) 0 var(--ink);
  animation: blink 1.2s steps(1, end) infinite;
}
.prompt.is-gone { display: none; }

/* ---------- title card ---------- */
.title {
  position: fixed;
  left: 0;
  right: 0;
  top: 40vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  opacity: 0;
  pointer-events: none;
}
.title.is-on { opacity: 1; }

.heading {
  margin: 0;
  font-weight: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.name {
  font-size: calc(var(--s) * 8 * var(--k));
  line-height: 1;
  filter:
    drop-shadow(0 var(--s) 0 #6b3d0e)
    drop-shadow(var(--o) 0 0 var(--ink))
    drop-shadow(calc(var(--o) * -1) 0 0 var(--ink))
    drop-shadow(0 var(--o) 0 var(--ink))
    drop-shadow(0 calc(var(--o) * -1) 0 var(--ink));
}
.w {
  display: inline-block;
  opacity: 0;
  background: linear-gradient(180deg, #fff6c8 0 25%, #f2c14e 25% 62%, #c98a1f 62% 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.title.stack .w { display: block; }
.title.stack .w + .w { margin-top: calc(var(--s) * 2); }

.sub {
  display: block;
  margin-top: calc(var(--s) * 5);
  padding-left: calc(var(--s) * 4);
  font-size: calc(var(--s) * 8);
  line-height: 1;
  letter-spacing: calc(var(--s) * 4);
  color: var(--cyan);
  opacity: 0;
  filter:
    drop-shadow(var(--o) 0 0 var(--ink))
    drop-shadow(calc(var(--o) * -1) 0 0 var(--ink))
    drop-shadow(0 var(--o) 0 var(--ink))
    drop-shadow(0 calc(var(--o) * -1) 0 var(--ink));
}

.about {
  margin-top: calc(var(--s) * 6);
  width: calc(100% - 32px);
  max-width: 52em;
  opacity: 0;
}
.title.is-on .about { pointer-events: auto; cursor: default; }

.menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em 2.2em;
  margin-top: 1em;
  opacity: 0;
  visibility: hidden;
}
.menu.is-on { opacity: 1; visibility: visible; }
.menu a {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  color: #fff;
  text-decoration: none;
  line-height: 1.6;
}
.menu a::before {
  content: '';
  width: 0.5em;
  height: 0.75em;
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  visibility: hidden;
}
.menu a:hover, .menu a:focus-visible { color: var(--gold-hi); outline: none; }
.menu .email { flex-basis: 100%; text-transform: none; overflow-wrap: anywhere; }
.menu a:hover::before,
.menu a:focus-visible::before,
.menu:not(:hover):not(:focus-within) a:first-child::before {
  visibility: visible;
  animation: blink 0.9s steps(1, end) infinite;
}

/* reveal sequence
   The finished look lives in these normal styles and the animations only fill backwards,
   so nothing depends on a browser holding the last animation frame. iPhone browsers (WebKit)
   can freeze a stepped animation one step short, which used to leave the about box cropped. */
.title.is-on .w, .title.is-on .sub, .title.is-on .about { opacity: 1; }
.title.is-on .w { animation: drop 0.5s steps(5, end) backwards; }
.title.is-on .w + .w { animation-delay: 0.1s; }
.title.is-on .sub { animation: wipe 0.45s steps(6, end) 0.5s backwards; }
.title.is-on .about { animation: wipe 0.35s steps(4, end) 0.95s backwards; }
.title.instant .w, .title.instant .sub, .title.instant .about { animation: none !important; }

/* ---------- sound toggle ---------- */
.sound {
  position: fixed;
  top: calc(var(--s) * 2);
  right: calc(var(--s) * 2);
  padding: 0.7em 0.8em;
  border: 0;
  background: rgba(4, 3, 12, 0.55);
  color: #c9d0ff;
  font-size: var(--ui-sm);
  line-height: 1;
  cursor: pointer;
}
.sound:hover, .sound:focus-visible { color: #fff; outline: none; background: rgba(4, 3, 12, 0.8); }

@keyframes blink { 50% { opacity: 0; } }
@keyframes drop {
  from { opacity: 0; transform: translateY(calc(var(--s) * -12)); }
  20% { opacity: 1; }
  to { opacity: 1; transform: none; }
}
@keyframes wipe {
  from { opacity: 1; clip-path: inset(-2em 100% -2em -2em); }
  to { opacity: 1; clip-path: inset(-2em -2em -2em -2em); }
}

@media (prefers-reduced-motion: reduce) {
  .prompt, .next, .menu a::before { animation: none !important; }
}
