@font-face {
  font-family: "ManaSpace";
  src: url("assets/manaspc.ttf") format("truetype");
  font-display: swap;
}

:root {
  --sky: #4a92d0;
  --grass: #c8f59a;
  --panel: #211c2b;
  --panel-2: #2c2539;
  --border: #b89a4d;
  --gold: #ffd659;
  --text: #f2e6c7;
  --dim: #c7bdad;
  --orange: #f0a43a;
  --orange-dark: #b8701c;
  --red: #e0605a;
  --green: #8fd46a;
  --ink: #120f18;
  --pixel: "ManaSpace", ui-monospace, monospace;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--sky); }

body {
  margin: 0;
  /* The logo's boxes fly in from beyond the page edges: no sideways scrollbar while they do. */
  overflow-x: clip;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  font: 16px/1.55 var(--body);
  background: var(--sky) url("assets/menu_background.png") center bottom / auto 100% repeat-x;
  image-rendering: pixelated;
}

a { color: var(--gold); }
a:hover { color: #fff1b3; }

/* --- Header -------------------------------------------------------------------------------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px clamp(16px, 4vw, 40px);
  background: rgba(18, 15, 24, 0.82);
  border-bottom: 3px solid var(--border);
}

.brand { display: block; line-height: 0; flex-shrink: 0; }
/* The pixel-art logo: each art pixel stays a sharp square, never blurred. */
.brand img, .studio-logo img { image-rendering: pixelated; }
/* The small logo (H and K boxes merged), at its own size: 2 screen pixels per art pixel. */
.brand img { width: 92px; height: 48px; }

.nav { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.nav a { font-family: var(--pixel); font-size: 12px; text-decoration: none; color: var(--text); padding: 6px 8px; }
.nav a:hover { color: var(--gold); }
.nav .who { font-size: 12px; color: var(--dim); font-family: var(--pixel); }

/* --- Layout -------------------------------------------------------------------------------- */

main {
  flex: 1;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(24px, 6vw, 56px) 16px 200px;
}

.panel {
  background: var(--panel);
  border: 3px solid var(--border);
  box-shadow: 6px 6px 0 rgba(18, 15, 24, 0.55);
  padding: clamp(20px, 4vw, 32px);
}

.narrow { max-width: 440px; margin: 0 auto; }

h1, h2, h3 {
  font-family: var(--pixel);
  font-weight: normal;
  color: var(--gold);
  line-height: 1.3;
  margin: 0 0 14px;
  text-shadow: 2px 2px 0 var(--ink);
}
h1 { font-size: clamp(20px, 4vw, 28px); }
h2 { font-size: clamp(16px, 3vw, 20px); }
h3 { font-size: 14px; }

p { margin: 0 0 14px; }
.dim { color: var(--dim); }
.small { font-size: 14px; }

/* --- Home ---------------------------------------------------------------------------------- */

.hero { text-align: center; margin-bottom: 28px; }
.studio-logo { margin: 0 0 12px; line-height: 0; }

/* --- Animated logo (home page) ---------------------------------------------------------------
   The logo is 92 x 44 art pixels; --u is one art pixel (6px at full size, smaller on phones).
   Positions are from the logo's left edge (art x 24) and top, as tools/make_logo.js prints them.
   Timeline, 2.1s: boxes fly in and collide (0.2-0.7s), judder, shift diagonally into place
   (1.05-1.5s), then the words slide out (1.5-2.05s) while the logo glides to the middle. */
.logo-anim {
  --u: calc(100cqw / 92);
  display: block;
  position: relative;
  width: min(552px, 100%);
  aspect-ratio: 92 / 44;
  margin: 0 auto;
  container-type: inline-size;
}
.logo-anim img { position: absolute; display: block; height: auto; image-rendering: pixelated; }
.la-cam, .la-shake { position: absolute; inset: 0; }.la-h { left: calc(2 * var(--u)); top: calc(4 * var(--u)); width: calc(22 * var(--u)); }
.la-k { left: calc(18 * var(--u)); top: calc(20 * var(--u)); width: calc(22 * var(--u)); }
/* Windows the words slide through, starting at each box's right edge. */
.la-win { position: absolute; overflow: hidden; }
.la-win-aven { left: calc(24 * var(--u)); top: calc(9 * var(--u)); width: calc(68 * var(--u)); height: calc(8 * var(--u)); }
.la-win-ein { left: calc(40 * var(--u)); top: calc(30 * var(--u)); width: calc(52 * var(--u)); height: calc(11 * var(--u)); }
.la-aven { left: var(--u); top: 0; width: calc(25 * var(--u)); }
.la-ein { left: var(--u); top: 0; width: calc(50 * var(--u)); }

.la-cam { animation: la-cam 2.1s both; }
.la-shake { animation: la-shake 2.1s both; }
.la-h { animation: la-h 2.1s both; }
.la-k { animation: la-k 2.1s both; }
.la-aven { animation: la-aven 2.1s both; }
.la-ein { animation: la-ein 2.1s both; }

/* Fly in, speeding up (ease-in), meet side by side; then spring into place (overshoot). */
@keyframes la-h {
  0%, 9.5% { transform: translate(calc(-163 * var(--u)), calc(8 * var(--u))); animation-timing-function: cubic-bezier(.55, 0, 1, .45); }
  33.3% { transform: translate(calc(-3 * var(--u)), calc(8 * var(--u))); }
  50% { transform: translate(calc(-3 * var(--u)), calc(8 * var(--u))); animation-timing-function: cubic-bezier(.34, 1.56, .64, 1); }
  71.4%, 100% { transform: translate(0, 0); }
}
@keyframes la-k {
  0%, 9.5% { transform: translate(calc(163 * var(--u)), calc(-8 * var(--u))); animation-timing-function: cubic-bezier(.55, 0, 1, .45); }
  33.3% { transform: translate(calc(3 * var(--u)), calc(-8 * var(--u))); }
  50% { transform: translate(calc(3 * var(--u)), calc(-8 * var(--u))); animation-timing-function: cubic-bezier(.34, 1.56, .64, 1); }
  71.4%, 100% { transform: translate(0, 0); }
}
/* The bump when they hit. */
@keyframes la-shake {
  0%, 33.3% { transform: none; }
  35.5% { transform: translateX(var(--u)); }
  38% { transform: translateX(calc(-1 * var(--u))); }
  40.5% { transform: translateX(calc(.5 * var(--u))); }
  42.9%, 100% { transform: none; }
}
/* Keep the boxes in the middle, then glide so the whole logo ends up in the middle. */
@keyframes la-cam {
  0%, 71.4% { transform: translateX(calc(25 * var(--u))); animation-timing-function: ease-in-out; }
  97.6%, 100% { transform: none; }
}
@keyframes la-aven {
  0%, 71.4% { transform: translateX(calc(-26 * var(--u))); animation-timing-function: cubic-bezier(.22, 1, .36, 1); }
  90.5%, 100% { transform: none; }
}
@keyframes la-ein {
  0%, 78.6% { transform: translateX(calc(-51 * var(--u))); animation-timing-function: cubic-bezier(.22, 1, .36, 1); }
  97.6%, 100% { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .logo-anim * { animation: none !important; }
}
.hero .tag { font-size: 18px; color: #fff; text-shadow: 2px 2px 0 rgba(18, 15, 24, 0.6); }

.game {
  display: grid;
  grid-template-columns: minmax(0, 300px) 1fr;
  gap: 28px;
  align-items: center;
}
.game img { width: 100%; height: auto; image-rendering: pixelated; }
.features { list-style: none; padding: 0; margin: 0 0 20px; }
.features li { padding-left: 22px; position: relative; margin-bottom: 6px; }
.features li::before { content: "\25B8"; position: absolute; left: 4px; color: var(--gold); }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 24px; }
.step { background: var(--panel-2); border: 2px solid #4a3f5c; padding: 16px; }
.step .num { font-family: var(--pixel); color: var(--orange); font-size: 18px; }

@media (max-width: 720px) {
  .game { grid-template-columns: 1fr; text-align: center; }
  .game img { max-width: 260px; margin: 0 auto; }
  .features { text-align: left; }
  .steps { grid-template-columns: 1fr; }
}

/* --- Buttons and forms --------------------------------------------------------------------- */

.btn {
  display: inline-block;
  font-family: var(--pixel);
  font-size: 15px;
  color: var(--ink);
  background: var(--orange);
  border: 3px solid var(--ink);
  box-shadow: inset 0 -4px 0 var(--orange-dark);
  padding: 10px 20px 12px;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}
.btn:hover { background: #ffb954; color: var(--ink); }
.btn:active { box-shadow: inset 0 4px 0 var(--orange-dark); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn.light { background: var(--text); box-shadow: inset 0 -4px 0 #a99d82; }
.btn.light:hover { background: #fff; }
.btn.red { background: var(--red); box-shadow: inset 0 -4px 0 #9b3631; }
.btn.block { display: block; width: 100%; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

form { display: grid; gap: 16px; }
label { display: grid; gap: 6px; font-size: 14px; color: var(--dim); }
input {
  font: 16px var(--body);
  color: var(--text);
  background: var(--ink);
  border: 2px solid #4a3f5c;
  padding: 10px 12px;
  width: 100%;
}
input:focus { border-color: var(--gold); outline: none; }
.hint { font-size: 12px; color: #9a8f80; }

.message { padding: 10px 12px; font-size: 14px; border: 2px solid; display: none; }
.message.show { display: block; }
.message.error { border-color: var(--red); color: #ffc4c0; background: rgba(224, 96, 90, 0.12); }
.message.ok { border-color: var(--green); color: #d9f7c7; background: rgba(143, 212, 106, 0.12); }

#welcome.show { margin-bottom: 18px; }

.switch { text-align: center; font-size: 14px; margin-top: 18px; color: var(--dim); }

/* --- Account ------------------------------------------------------------------------------- */

dl.info { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 0 0 22px; }
dl.info dt { color: var(--dim); font-size: 14px; }
dl.info dd { margin: 0; overflow-wrap: anywhere; }
code { font-family: var(--pixel); font-size: 13px; color: var(--gold); background: var(--ink); padding: 2px 6px; }

footer {
  text-align: center;
  font-size: 12px;
  padding: 10px 16px;
  background: rgba(18, 15, 24, 0.82);
  color: var(--dim);
}
footer a { color: var(--dim); }
