/* ai game maker — one page, one stylesheet, no frameworks, no external fonts */
:root {
  --bg: #fbfbfc;
  --surface: #ffffff;
  --ink: #101114;
  --muted: #4f545c;
  --faint: #6b707a;
  --line: #e8e9ee;
  --line-strong: #d8dae2;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef0fe;
  --accent: #0f766e;
  --accent-soft: #ecfdf5;

  --ok-bg: #ecfdf5; --ok-line: #a7f3d0; --ok-ink: #065f46;
  --err-bg: #fef2f2; --err-line: #fecaca; --err-ink: #b91c1c;

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px;
  --shadow-1: 0 1px 2px rgba(16, 17, 20 .05), 0 1px 1px rgba(16, 17, 20 .04);
  --shadow-2: 0 2px 6px rgba(16, 17, 20 .06), 0 8px 24px rgba(16, 17, 20 .07);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--primary); color: #fff; }

kbd {
  font-family: var(--mono);
  font-size: .78em;
  padding: .12em .38em;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(16px, 4vw, 40px);
  height: 56px;
  background: rgba(251, 251, 252, .88);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 700; letter-spacing: -.01em;
  color: var(--ink); text-decoration: none;
  font-size: 15.5px;
}
.brand-mark { width: 22px; height: 22px; fill: var(--primary); }
.brand-mark .bm-dot { fill: #fff; }
.topnav { display: flex; gap: clamp(12px, 3vw, 28px); }
.topnav a {
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 550;
  padding: 6px 2px; border-radius: 6px;
}
.topnav a:hover { color: var(--ink); }
.topnav a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- hero / first screen ---------- */
.hero {
  max-width: 1160px;
  margin: 0 auto;
  padding: clamp(28px, 5vh, 56px) clamp(16px, 4vw, 40px) clamp(40px, 7vh, 72px);
  display: grid;
  grid-template-columns: minmax(360px, 480px) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 48px);
  align-items: start;
  background:
    radial-gradient(60% 50% at 18% 0%, rgba(79, 70, 229, .05), transparent 70%);
}
.eyebrow {
  margin: 0 0 14px;
  font-size: 13px; font-weight: 600;
  color: var(--accent);
  letter-spacing: .02em;
}
h1 {
  margin: 0 0 14px;
  font-size: clamp(30px, 4.2vw, 46px);
  line-height: 1.08;
  letter-spacing: -.025em;
  font-weight: 780;
}
h1 em { font-style: normal; color: var(--primary); }
.sub {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 16.5px;
  max-width: 46ch;
}
.sub strong { color: var(--ink); font-weight: 620; }

/* tool form */
.tool {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: 14px 14px 12px;
}
.field-label {
  display: block;
  font-size: 12.5px; font-weight: 650;
  color: var(--muted);
  margin: 2px 2px 8px;
  letter-spacing: .01em;
}
#desc {
  width: 100%;
  resize: vertical;
  min-height: 84px;
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--ink);
  padding: 11px 12px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-md);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#desc::placeholder { color: var(--faint); }
#desc:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px rgba(79, 70, 229, .14);
}
#desc.is-invalid { border-color: var(--err-ink); }
#desc.is-invalid:focus { box-shadow: 0 0 0 3.5px rgba(185, 28, 28, .12); }
.tool-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 10px; flex-wrap: wrap;
}
.tool-hint { margin: 0; font-size: 12.5px; color: var(--faint); }
.btn-primary {
  appearance: none; border: 0; cursor: pointer;
  font-family: var(--font); font-size: 15px; font-weight: 650;
  color: #fff; background: var(--primary);
  padding: 11px 22px;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(79, 70, 229, .35), inset 0 1px 0 rgba(255,255,255,.14);
  transition: background .15s ease, transform .06s ease, box-shadow .15s ease;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(.975); }
.btn-primary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2.5px; }
.btn-primary[disabled] { opacity: .55; cursor: progress; }
.field-msg { margin: 8px 2px 0; min-height: 18px; font-size: 13px; }
.field-msg.error { color: var(--err-ink); font-weight: 550; }

/* presets */
.presets { margin-top: 18px; }
.presets-label { font-size: 13px; color: var(--faint); font-weight: 600; margin-right: 8px; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chip {
  appearance: none; cursor: pointer;
  font-family: var(--font); font-size: 13px; font-weight: 550;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 14px;
  transition: border-color .15s ease, background .15s ease, transform .06s ease;
}
.chip::before { content: "▸ "; color: var(--primary); font-size: 11px; }
.chip:hover { border-color: var(--primary); background: var(--primary-soft); }
.chip:active { transform: scale(.97); }
.chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- answer column (result) ---------- */
.answer { min-height: 430px; min-width: 0; display: flex; }
.result-empty {
  flex: 1;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-xl);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 32px 28px;
  color: var(--faint);
  background:
    radial-gradient(70% 60% at 50% 40%, rgba(79,70,229,.035), transparent 75%);
}
.empty-glyph { width: 40px; height: 40px; margin-bottom: 14px; color: var(--primary); opacity: .8; }
.empty-title { margin: 0 0 6px; font-size: 16px; font-weight: 650; color: var(--muted); }
.empty-sub { margin: 0; font-size: 13.5px; max-width: 34ch; }

.result-card {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  animation: rise .18s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

.result-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.result-badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.badge {
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--primary); background: var(--primary-soft);
  border-radius: 6px; padding: 4px 8px;
}
.badge-ghost { color: var(--muted); background: #f4f4f6; }
.result-title { margin: 0; font-size: 21px; letter-spacing: -.015em; font-weight: 720; }
.spec-strip {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: #f7f7f9;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  overflow-x: auto;
  white-space: nowrap;
}
.spec-strip b { color: var(--accent); font-weight: 700; }
.spec-strip .src { color: var(--faint); }

.stage { position: relative; background: #0c0d12; min-width: 0; }
#game-canvas, .stage canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  touch-action: none;
}
.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center;
  background: rgba(10, 11, 16, .62);
  backdrop-filter: blur(2px);
  color: #fff;
  padding: 20px;
}
.overlay[hidden] { display: none; }
.overlay-title { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.overlay-sub { margin: 0; font-size: 13.5px; color: rgba(255,255,255,.75); }
.overlay .btn-primary { margin-top: 10px; }
.overlay .btn-ghost { margin-top: 8px; }

.hud {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--muted);
  background: var(--surface);
}
.hud b { color: var(--ink); font-weight: 680; font-variant-numeric: tabular-nums; }
.hud .hud-dot { color: var(--faint); }
.stage-keys {
  margin: 0;
  padding: 11px 18px 0;
  font-size: 12.5px;
  color: var(--faint);
  text-align: center;
  letter-spacing: .01em;
}

.result-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 13px 18px 15px;
}
.btn-ghost {
  appearance: none; cursor: pointer;
  font-family: var(--font); font-size: 13.5px; font-weight: 600;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 9px; padding: 9px 14px;
  transition: border-color .15s ease, background .15s ease, transform .06s ease;
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost:active { transform: scale(.97); }
.btn-ghost:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-ghost.copied { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ok-ink); }
.share-url {
  flex: 1 1 220px; min-width: 0;
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  border: 1px dashed var(--line-strong); border-radius: var(--r-sm);
  padding: 9px 10px;
  background: #fafafb;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* touch controls */
.touchpad { display: none; }
@media (pointer: coarse) {
  .touchpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  }
  .tbtn {
    appearance: none; border: 1.5px solid var(--line-strong); background: var(--surface);
    border-radius: var(--r-md);
    height: 58px;
    font-size: 21px; color: var(--ink);
    display: flex; align-items: center; justify-content: center;
    touch-action: manipulation; user-select: none; -webkit-user-select: none;
  }
  .tbtn:active { background: var(--primary-soft); border-color: var(--primary); }
  .tbtn-wide { grid-column: span 3; font-size: 14px; font-weight: 650; height: 50px; }
}

/* ---------- content sections ---------- */
.section {
  max-width: 1160px;
  margin: 0 auto;
  padding: clamp(44px, 7vh, 76px) clamp(16px, 4vw, 40px) 0;
}
.kicker {
  margin: 0 0 10px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--accent);
}
h2 {
  margin: 0 0 34px;
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: -.02em; font-weight: 740;
  max-width: 22ch;
}
.steps {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
  counter-reset: step;
}
.steps li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px 22px 20px;
  counter-increment: step;
  position: relative;
  box-shadow: var(--shadow-1);
}
.steps li::before {
  content: counter(step);
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--primary-soft); color: var(--primary);
  font-size: 13px; font-weight: 750;
  margin-bottom: 12px;
}
.steps h3 { margin: 0 0 8px; font-size: 16.5px; letter-spacing: -.01em; }
.steps p { margin: 0; font-size: 14px; color: var(--muted); }

.grid-4 {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-1);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.card h3 { margin: 0 0 8px; font-size: 16px; letter-spacing: -.01em; }
.card p { margin: 0; font-size: 13.5px; color: var(--muted); }
.card-keys { margin-top: 12px !important; font-size: 12px !important; color: var(--faint) !important; }

.themes { margin-top: 34px; }
.themes h3 { font-size: 15px; margin: 0 0 14px; }
.theme-list {
  list-style: none; display: flex; flex-wrap: wrap; gap: 10px 26px;
  margin: 0; padding: 0;
  font-size: 14px; color: var(--muted);
}
.theme-list li { display: inline-flex; align-items: center; gap: 9px; }
.sw {
  width: 15px; height: 15px; border-radius: 5px;
  background: var(--sw);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.scope-note {
  margin: 30px 0 0;
  font-size: 14px; color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: var(--r-md);
  padding: 15px 18px;
  max-width: 76ch;
}
.scope-note strong { color: var(--ink); }

.faq-list { max-width: 760px; }
.faq-list details {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-md);
  margin-bottom: 10px;
  overflow: hidden;
}
.faq-list summary {
  cursor: pointer;
  list-style: none;
  padding: 15px 18px;
  font-weight: 640; font-size: 15px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary::after {
  content: "+";
  font-family: var(--mono); font-size: 17px; color: var(--primary); font-weight: 700;
  transition: transform .15s ease;
}
.faq-list details[open] summary::after { transform: rotate(45deg); }
.faq-list details p {
  margin: 0; padding: 0 18px 16px;
  color: var(--muted); font-size: 14.5px;
  border-top: 1px solid var(--line); padding-top: 13px;
}

/* ---------- footer ---------- */
.footer {
  max-width: 1160px;
  margin: clamp(48px, 8vh, 84px) auto 0;
  padding: 26px clamp(16px, 4vw, 40px) 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13.5px;
}
.footer p { margin: 0 0 6px; }
.footer strong { color: var(--ink); }
.foot-note { color: var(--faint); font-size: 12.5px; }

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

/* ---------- responsive ---------- */
@media (max-width: 1020px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .answer { min-height: 400px; }
  .steps { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  body { font-size: 15.5px; }
  .topnav { display: none; }
  .hero { padding-top: 22px; }
  .steps, .grid-4 { grid-template-columns: 1fr; }
  .answer { min-height: 340px; }
  .tool-row { align-items: stretch; }
  .btn-primary { width: 100%; }
  .hud { gap: 12px; flex-wrap: wrap; }
  .result-foot { flex-direction: column; align-items: stretch; }
  .share-url { flex: none; }
}

/* ---------- motion: short, respectful ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
