/* ============================================================
   Creed's Mansion — retro arcade theme
   Palette lifted from the Shining Force window chrome:
   deep blue interiors, double gold frames, white pixel text.
   ============================================================ */

@font-face {
  font-family: 'Press Start 2P';
  src: url('fonts/press-start-2p.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

/* The game's own dialogue typeface: the 16x14 bitmaps from the Mega Drive
   variable-width font, traced into outlines. One source pixel = 1 CSS px at
   font-size 14px, so the text is pixel-exact at that size (and at 28px, 42px…). */
@font-face {
  font-family: 'SF Dialogue';
  src: url('fonts/sf-dialogue.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  --bg:          #07070f;
  --bg-2:        #0d0d1c;
  --win:         #002083;   /* the game's flat window blue */
  --win-dark:    #001347;
  --gold:        #dcba6b;   /* frame: gold band */
  --gold-dark:   #7a4a0a;   /* frame: outer dark band */
  --gold-light:  #f0e2c0;   /* frame: cream highlight band */
  --frame-in:    #6b4429;   /* frame: inner dark line */
  --frame-out:   #0b0300;   /* frame: black outline */
  --ink:         #ffffff;
  --ink-dim:     #dbe4ff;   /* dialogue text, the pale blue-white the game uses */
  --accent:      #ff9c20;
  --green:       #58d048;
  --red:         #e04038;
  --pixel: 'Press Start 2P', 'Courier New', monospace;
  --body: 'SF Dialogue', 'Georgia', 'Times New Roman', serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Consolas', 'Liberation Mono', monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 50% -10%, #16204a 0%, transparent 60%),
    repeating-linear-gradient(0deg, rgba(0,0,0,.30) 0 2px, transparent 2px 4px);
  color: var(--ink);
  font-family: var(--body);
  font-size: 21px;      /* 1.5x the game's own pixel grid */
  line-height: 32px;
  -webkit-font-smoothing: antialiased;
}

img { image-rendering: pixelated; image-rendering: crisp-edges; max-width: 100%; }

a { color: var(--accent); text-decoration: none; border-bottom: 1px dotted rgba(255,156,32,.5); }
a:hover { color: var(--gold-light); border-bottom-color: var(--gold-light); }

.wrap { width: min(1120px, 90vw); margin: 0 auto; }

/* ---------- pixel headings ---------- */
h1, h2, h3, .pixel {
  font-family: var(--pixel);
  font-weight: 400;
  line-height: 1.7;
  letter-spacing: .02em;
  text-transform: uppercase;
  overflow-wrap: break-word;
}
h1 { font-size: clamp(14px, 2.6vw, 24px); margin: 0 0 .6em; }
h2 { font-size: clamp(12px, 1.9vw, 18px); margin: 2.2em 0 1em; color: var(--gold); }
h2 .tag { margin-left: .8em; vertical-align: 2px; }
h3 { font-size: clamp(10px, 1.4vw, 15px); margin: 1.8em 0 .8em; color: var(--gold-light); }

p  { margin: 0 0 1.1em; color: #98a6d4; }
.win p, .win li, .win dd { color: var(--ink-dim); }
p strong, li strong { color: var(--ink); }
code {
  font-family: var(--mono);
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(240,192,96,.25);
  padding: .1em .4em;
  font-size: 16px;
  color: var(--gold-light);
}

/* ---------- the Shining Force window ---------- */
.win {
  /* Frame rebuilt band by band from the Shining Force window tiles:
     blue interior, thin dark line, cream highlight, gold, dark brown, black. */
  position: relative;
  background: var(--win);
  border: 2px solid var(--frame-in);
  border-radius: 10px;
  box-shadow:
    0 0 0 4px var(--gold-light),
    0 0 0 8px var(--gold),
    0 0 0 11px var(--gold-dark),
    0 0 0 13px var(--frame-out),
    0 7px 0 13px rgba(0,0,0,.5);
  padding: 1.5rem 1.7rem;
  margin: 2rem 0;
  color: var(--ink-dim);
}
/* keep the measure readable: the game's font is small, the page is not */
.win > p, .win > ul, .win > dl, .win > h3 + p { max-width: 84ch; }
.win > :first-child { margin-top: 0; }
.win > :last-child  { margin-bottom: 0; }

.win-plain { background: #0d1030; }   /* same frame, unlit interior */

/* ---------- top bar ---------- */
header.bar {
  border-bottom: 3px solid var(--gold-dark);
  background: linear-gradient(180deg, #0b0b18 0%, #05050c 100%);
  position: sticky; top: 0; z-index: 20;
}
header.bar .wrap {
  display: flex; align-items: center; gap: 1.2rem;
  padding: .9rem 0; flex-wrap: wrap;
}
.brand {
  font-family: var(--pixel); font-size: 13px; color: var(--gold);
  border: none; letter-spacing: .04em;
}
.brand:hover { color: var(--gold-light); }
nav.main { margin-left: auto; display: flex; gap: 1.4rem; flex-wrap: wrap; }
nav.main a {
  font-family: var(--pixel); font-size: 10px; color: var(--ink-dim);
  border: none; text-transform: uppercase; letter-spacing: .05em;
}
nav.main a:hover, nav.main a[aria-current] { color: var(--accent); }
nav.main a[aria-current]::before { content: '\25B8 '; color: var(--accent); }

nav.main a.tea { display: inline-flex; align-items: center; gap: .55em; }
nav.main a.tea img {
  width: 16px; height: 16px; display: block;
  image-rendering: pixelated; image-rendering: crisp-edges;
}

/* ---------- hero ---------- */
.hero { padding: 3.2rem 0 1rem; text-align: center; }

/* the wordmark */
.logo { margin: 0 0 1.2rem; line-height: 0; }
.logo img {
  display: block; width: min(860px, 100%); height: auto; margin: 0 auto;
  image-rendering: auto;                 /* painted artwork, not pixel art */
  filter: drop-shadow(0 8px 14px rgba(0,0,0,.65));
}
@media (max-width: 640px) { .logo img { width: 100%; } }

.hero .title {
  font-family: var(--pixel);
  font-size: clamp(15px, 4vw, 34px);
  line-height: 1.5;
  overflow-wrap: break-word;
  color: var(--gold);
  text-shadow: 0 3px 0 var(--gold-dark), 0 6px 0 #000, 0 0 26px rgba(240,192,96,.35);
  margin: 0 0 1rem;
}
.hero .sub {
  font-family: var(--pixel); font-size: clamp(7px, 1.2vw, 11px);
  color: var(--ink-dim); letter-spacing: .12em; margin: 0;
}
.cursor::after {
  content: '\25AE'; color: var(--accent); margin-left: .35em;
  animation: blink 1.05s steps(1) infinite;
}
@keyframes blink { 0%,49% { opacity: 1 } 50%,100% { opacity: 0 } }

/* ---------- cards ---------- */
.grid { display: grid; gap: 2.8rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.card { display: block; border-bottom: none; color: inherit; }
.card .win { margin: 0; height: 100%; transition: transform .12s steps(2), box-shadow .12s; }
.card:hover .win {
  transform: translate(-2px, -4px);
  box-shadow:
    0 0 0 4px var(--gold-light), 0 0 0 8px var(--gold), 0 0 0 11px var(--gold-dark),
    0 0 0 13px var(--frame-out), 0 11px 0 13px rgba(0,0,0,.55);
}
.card h3 { margin-top: 0; color: var(--gold); }
.grid + p { margin-top: 2.4rem; }   /* clear the cards' frame rings */
.card p { margin-bottom: 0; }

.tag {
  display: inline-block; font-family: var(--pixel); font-size: 10px;
  padding: .45em .7em; border: 2px solid currentColor; letter-spacing: .06em;
  vertical-align: middle;
}
.tag.new  { color: var(--green); }
.tag.ver  { color: var(--gold); }
.tag.soon { color: #6a7398; }
.tag.plat { color: var(--ink-dim); }

/* ---------- feature blocks ---------- */
.feature { display: grid; gap: 1.6rem; align-items: start; margin: 2.2rem 0; }
@media (min-width: 1024px) {
  /* 512px keeps every screenshot at an exact 2x of the Mega Drive's 256x224 */
  .feature { grid-template-columns: 512px minmax(0, 1fr); gap: 2.2rem; }
  .feature.flip { grid-template-columns: minmax(0, 1fr) 512px; }
  .feature.flip .shot { order: 2; }
}
.shot { margin: 0 0 0 7px; }
.shot img {
  display: block; width: 100%; max-width: 512px; height: auto;
  border: 2px solid var(--frame-in); border-radius: 4px; background: #000;
  box-shadow: 0 0 0 3px var(--gold-light), 0 0 0 5px var(--gold-dark), 0 0 0 7px var(--frame-out);
}
/* already-resampled captures look better smoothed than nearest-neighboured */
.shot img.smooth { image-rendering: auto; }
.shot figcaption {
  font-family: var(--pixel); font-size: 9px; color: #7f8bb5;
  margin-top: .8rem; line-height: 1.9; letter-spacing: .04em;
}

/* ---------- lists ---------- */
ul.spec { list-style: none; padding: 0; margin: 0; }
ul.spec li {
  padding: .5rem 0 .5rem 1.6rem; position: relative;
  border-bottom: 1px dotted rgba(240,192,96,.18); color: var(--ink-dim);
}
ul.spec li:last-child { border-bottom: none; }
ul.spec li::before {
  content: '\25C6'; position: absolute; left: 0; top: .55rem;
  color: var(--gold); font-size: 13px;
}

dl.kv { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.4rem; }
dl.kv dt { font-family: var(--pixel); font-size: 10px; color: var(--gold); padding-top: .35em; }
dl.kv dd { margin: 0; color: var(--ink-dim); }

/* ---------- buttons ---------- */
.btn {
  display: inline-block; font-family: var(--pixel); font-size: 11px;
  padding: 1rem 1.4rem; color: #2a1a00; background: var(--gold-light);
  border: 2px solid var(--gold-dark); border-radius: 6px;
  box-shadow: 0 0 0 2px var(--frame-out), 0 5px 0 2px rgba(0,0,0,.5);
  text-transform: uppercase; letter-spacing: .04em;
}
.btn:hover { background: #fff6e0; transform: translateY(2px); box-shadow: 0 0 0 2px var(--frame-out), 0 3px 0 2px rgba(0,0,0,.5); }
.btn.ghost { background: transparent; color: var(--gold-light); box-shadow: 0 0 0 2px var(--frame-out); border-color: var(--gold-dark); }
.btn.ghost:hover { color: var(--gold-light); border-color: var(--gold); background: rgba(240,192,96,.08); }
.btnrow { display: flex; gap: 1.4rem; flex-wrap: wrap; align-items: center; margin: 1.6rem 0 .6rem; }

/* ---------- misc ---------- */
.note {
  border-left: 4px solid var(--accent); padding: .2rem 0 .2rem 1.1rem;
  color: var(--ink-dim); margin: 1.4rem 0;
}
.rule { border: none; border-top: 2px dashed rgba(240,192,96,.3); margin: 3rem 0; }
.center { text-align: center; }
.small { font-size: 17px; }
.muted { color: #7f8bb5; }

footer.foot {
  border-top: 3px solid var(--gold-dark);
  margin-top: 4rem; padding: 2rem 0 3rem;
  color: #7f8bb5;
  background: linear-gradient(180deg, #05050c 0%, #000 100%);
}
footer.foot a { color: #93a0c8; }

.crumbs { font-family: var(--pixel); font-size: 9px; color: #6a7398; margin: 1.8rem 0 .4rem; letter-spacing: .05em; }
.crumbs a { border: none; color: #93a0c8; }
.crumbs a:hover { color: var(--accent); }

.changelog { list-style: none; padding: 0; margin: 0; }
.changelog li { margin-bottom: 1.2rem; }
.changelog .ver-tag {
  font-family: var(--pixel); font-size: 10px; color: var(--gold);
  display: inline-block; margin-right: .6rem;
}

/* ---------- narrow screens ---------- */
dl.kv dd, dl.kv dd code { overflow-wrap: anywhere; }
code { overflow-wrap: anywhere; }
@media (max-width: 640px) {
  body { font-size: 18px; line-height: 28px; }
  dl.kv { grid-template-columns: 1fr; gap: 0; }
  dl.kv dt { margin-top: 1rem; }
  .win { padding: 1.2rem 1.1rem; }
  .btn { font-size: 10px; padding: .9rem 1rem; }
  .btnrow { gap: 1rem; }
  .shot { margin-left: 0; }
}

/* ---------- game intro with cover art ---------- */
.win.intro { overflow: hidden; }
.cover { margin: 0 1.6rem 1rem 0; float: left; }
.cover img {
  display: block; width: 190px; height: auto;
  border: 2px solid var(--frame-in); border-radius: 4px; background: #000;
  box-shadow: 0 0 0 3px var(--gold-light), 0 0 0 5px var(--gold-dark), 0 0 0 7px var(--frame-out);
  image-rendering: auto;
}
.win.intro > p { max-width: none; }
@media (max-width: 620px) {
  .cover { float: none; margin: 0 auto 1.4rem; }
  .cover img { width: 160px; margin: 0 auto; }
}

/* ---------- long-form technical article ---------- */
pre.asm {
  font-family: var(--mono);
  font-size: 14px; line-height: 1.65;
  background: #06060f;
  border: 2px solid var(--frame-in);
  border-left: 4px solid var(--gold-dark);
  border-radius: 4px;
  padding: 1rem 1.1rem;
  margin: 1.4rem 0;
  overflow-x: auto;
  color: #b9c6f2;
  -webkit-overflow-scrolling: touch;
}
pre.asm b   { color: var(--gold-light); font-weight: 400; }   /* addresses */
pre.asm i   { color: #6f7cab; font-style: normal; }           /* comments */
pre.asm u   { color: var(--accent); text-decoration: none; }  /* the line that matters */

table.data {
  width: 100%; border-collapse: collapse; margin: 1.4rem 0;
  font-size: 17px; color: var(--ink-dim);
}
table.data th, table.data td {
  border: 1px solid rgba(240,192,96,.22);
  padding: .5rem .6rem; text-align: left; vertical-align: top;
}
table.data th {
  font-family: var(--pixel); font-size: 9px; color: var(--gold);
  letter-spacing: .04em; line-height: 1.8; background: rgba(0,0,0,.35);
}
table.data td.n { font-family: var(--mono); font-size: 14px; color: var(--gold-light); white-space: nowrap; }
table.data tr:nth-child(even) td { background: rgba(255,255,255,.03); }
table.data td.hit { color: var(--gold); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

figure.fig { margin: 2rem 0; }
figure.fig img {
  display: block; width: 100%; height: auto;
  border: 2px solid var(--frame-in); border-radius: 4px; background: #0d1030;
  image-rendering: auto;
}
figure.fig.px img { image-rendering: pixelated; }
figure.fig figcaption {
  font-family: var(--pixel); font-size: 9px; color: #7f8bb5;
  margin-top: .8rem; line-height: 1.9; letter-spacing: .04em;
}

.tldr { border-left: 4px solid var(--gold); }
.tldr h3 { margin-top: 0; }

ol.steps { counter-reset: st; list-style: none; padding: 0; margin: 1.2rem 0; }
ol.steps li {
  counter-increment: st; position: relative;
  padding: .55rem 0 .55rem 2.6rem; color: var(--ink-dim);
  border-bottom: 1px dotted rgba(240,192,96,.18);
}
ol.steps li:last-child { border-bottom: none; }
ol.steps li::before {
  content: counter(st); position: absolute; left: 0; top: .6rem;
  font-family: var(--pixel); font-size: 11px; color: var(--gold);
}

/* pixel-art figures: cap at an exact multiple of the Mega Drive's 256px */
figure.fig.px img { max-width: 1024px; margin: 0 auto; }

/* ---------- contact form ---------- */
.form-grid { display: grid; gap: 1.2rem; margin: 0; }
@media (min-width: 720px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }

.field { display: block; }
.field > span {
  display: block; font-family: var(--pixel); font-size: 10px; color: var(--gold);
  letter-spacing: .05em; margin-bottom: .6rem; line-height: 1.8;
}
.field > span .req { color: var(--accent); }

input[type="text"], input[type="email"], select, textarea {
  width: 100%;
  font-family: var(--body); font-size: 19px; line-height: 28px;
  color: var(--ink);
  background: #06060f;
  border: 2px solid var(--frame-in);
  border-radius: 4px;
  padding: .6rem .75rem;
  outline: none;
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%),
                    linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position: right 1.05rem top 1.25rem, right .75rem top 1.25rem;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
}
select option { background: #06060f; color: var(--ink); }
textarea { min-height: 11rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: #5b6690; }
input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(240,192,96,.18);
}
input:user-invalid, textarea:user-invalid { border-color: var(--red); }

.form-note { font-size: 17px; color: #7f8bb5; margin: .4rem 0 0; }

button.btn { font: inherit; font-family: var(--pixel); cursor: pointer; }
button.btn[disabled] { opacity: .55; cursor: default; }

.form-status { margin: 1.4rem 0 0; font-size: 19px; min-height: 1.2em; }
.form-status.ok   { color: var(--green); }
.form-status.err  { color: var(--red); }
.form-status.busy { color: var(--gold-light); }
.hp { position: absolute; left: -9999px; opacity: 0; height: 0; width: 0; }
