/* ---------- Tokens ---------- */
:root {
  --bg: #0f1218;
  --bg-2: #141922;
  --panel: #171d27;
  --panel-2: #1d2430;
  --line: #2b3444;
  --line-2: #3a4558;
  --text: #e7eaf0;
  --muted: #8d97a8;
  --accent: #ffb547;   /* gold */
  --accent-ink: #1a1306;
  --xp: #5be49b;       /* green */
  --mp: #6aa8ff;       /* blue */
  --hp: #ff6b7a;       /* red */
  --code-bg: #10141b;
  --grid: rgba(255, 255, 255, 0.025);
  --shadow: 0 0 0 1px #0008, 0 10px 30px -12px #000a;

  --f-body: "IBM Plex Sans", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, monospace;
  --f-px: "Silkscreen", var(--f-mono);
  --step: 4px;
  --radius: 2px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3efe6;
    --bg-2: #ebe5d8;
    --panel: #fffcf5;
    --panel-2: #f6f1e6;
    --line: #d9d0bd;
    --line-2: #c4b9a2;
    --text: #1f232b;
    --muted: #6b6457;
    --accent: #b46a00;
    --accent-ink: #fffaf0;
    --xp: #17925a;
    --mp: #2f6fd6;
    --hp: #c8343f;
    --code-bg: #f8f4ea;
    --grid: rgba(0, 0, 0, 0.035);
    --shadow: 0 0 0 1px #0000000d, 0 10px 24px -14px #0003;
    color-scheme: light;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--text);
  font: 400 17px/1.65 var(--f-body);
}
main { flex: 1; padding-bottom: 72px; }
a { color: inherit; text-decoration-color: color-mix(in srgb, var(--accent) 60%, transparent); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; font-weight: 600; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
kbd { font-family: var(--f-mono); }
.muted { color: var(--muted); }
.px { font-family: var(--f-px); font-weight: 400; letter-spacing: .04em; text-transform: uppercase; }
.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }
.narrow { width: min(760px, 100% - 32px); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

/* Stepped "pixel" corners, the main game cue */
.panel {
  position: relative;
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 22px 24px;
  clip-path: polygon(
    0 var(--step), var(--step) var(--step), var(--step) 0,
    calc(100% - var(--step)) 0, calc(100% - var(--step)) var(--step), 100% var(--step),
    100% calc(100% - var(--step)), calc(100% - var(--step)) calc(100% - var(--step)), calc(100% - var(--step)) 100%,
    var(--step) 100%, var(--step) calc(100% - var(--step)), 0 calc(100% - var(--step))
  );
}
.panel-title { font-size: .8rem; color: var(--accent); margin-bottom: 14px; }
.eyebrow { font-size: .78rem; color: var(--accent); margin-bottom: 10px; }
.eyebrow a { text-decoration: none; }
.section-title { font-size: .85rem; color: var(--muted); margin: 44px 0 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: 600 .9rem/1 var(--f-body);
  padding: 11px 16px;
  background: var(--accent); color: var(--accent-ink);
  border: 2px solid var(--accent);
  text-decoration: none; cursor: pointer;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 45%, #000);
  transform: translateY(0); transition: transform .08s, box-shadow .08s;
}
.btn:hover { color: var(--accent-ink); transform: translateY(1px); box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 45%, #000); }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 transparent; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line-2); box-shadow: 0 4px 0 var(--line); }
.btn-ghost:hover { color: var(--accent); box-shadow: 0 3px 0 var(--line); }

/* ---------- HUD ---------- */
.hud {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px max(16px, (100% - 1120px) / 2);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--line);
}
.hud-id {
  display: grid; grid-template-columns: 36px auto; grid-template-rows: auto auto auto;
  column-gap: 10px; align-items: center; text-decoration: none;
}
.hud-sprite { grid-row: 1 / 4; image-rendering: pixelated; background: var(--panel-2); border: 2px solid var(--line); }
.hud-name { font-weight: 600; font-size: .95rem; line-height: 1.1; }
.hud-meta { display: flex; gap: 8px; font-size: .72rem; color: var(--muted); line-height: 1.3; }
.hud-meta .px { color: var(--xp); }
.hud-xp { display: block; height: 4px; width: 100%; max-width: 150px; background: var(--line); margin-top: 3px; }
.hud-xp span { display: block; height: 100%; background: var(--xp); }
.hud-nav { display: flex; gap: 4px; }
.hud-nav a {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; text-decoration: none; font-size: .92rem; font-weight: 500;
  border: 2px solid transparent;
}
.hud-nav kbd {
  font-size: .7rem; line-height: 1; padding: 3px 5px;
  border: 1px solid var(--line-2); border-bottom-width: 2px; color: var(--muted);
}
.hud-nav a:hover { border-color: var(--line); color: var(--text); }
.hud-nav a[aria-current="page"] { border-color: var(--accent); color: var(--accent); }
.hud-nav a[aria-current="page"] kbd { border-color: var(--accent); color: var(--accent); }

/* ---------- Title screen ---------- */
.title-screen { padding: 72px 0 40px; }
.title {
  font-size: clamp(3rem, 11vw, 7.5rem);
  line-height: .92; letter-spacing: -.035em; font-weight: 600;
  margin: 0 0 32px;
}
.home .title { text-shadow: 4px 4px 0 color-mix(in srgb, var(--accent) 30%, transparent); }
.dialog { max-width: 720px; padding-top: 26px; margin-bottom: 28px; border-color: var(--line-2); }
.dialog-speaker {
  position: absolute; top: 0; left: 16px;
  font-size: .72rem; color: var(--accent-ink); background: var(--accent);
  padding: 3px 8px;
}
.dialog-text { position: relative; font-size: 1.12rem; margin: 0; }
.tw-ghost { color: transparent; }
.tw-live { position: absolute; inset: 0; }
.dialog-next { position: absolute; right: 16px; bottom: 8px; font-size: .7rem; color: var(--accent); animation: bob 1s steps(2) infinite; }
@keyframes bob { 50% { transform: translateY(3px); } }
.dialog.typing .dialog-next { visibility: hidden; }

.menu { display: grid; gap: 2px; max-width: 520px; }
.menu a {
  position: relative; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px;
  padding: 12px 14px 12px 40px; text-decoration: none; border: 2px solid transparent;
}
.menu a::before {
  content: "▶"; position: absolute; left: 14px; top: 14px; font-size: .8rem;
  color: var(--accent); opacity: 0; transform: translateX(-4px); transition: opacity .1s, transform .1s;
}
.menu a:hover, .menu a:focus-visible, .menu a.is-active { border-color: var(--line); background: var(--panel); color: var(--text); outline: none; }
.menu a:hover::before, .menu a:focus-visible::before, .menu a.is-active::before { opacity: 1; transform: none; animation: nudge .6s steps(2) infinite; }
@keyframes nudge { 50% { transform: translateX(3px); } }
.menu-label { font-size: 1.2rem; font-weight: 600; }
.menu-hint { font-size: .85rem; color: var(--muted); }
.menu-help { font-size: .68rem; color: var(--muted); margin-top: 12px; padding-left: 14px; }

.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.latest { display: grid; gap: 4px; text-decoration: none; }
.latest-meta { font: .78rem var(--f-mono); color: var(--muted); }
.latest-title { font-size: 1.3rem; font-weight: 600; line-height: 1.25; }
.latest:hover .latest-title { color: var(--accent); }
.latest-desc { color: var(--muted); }
.achievements { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.achievements li { display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: center; line-height: 1.35; font-size: .95rem; }
.ach-icon {
  display: grid; place-items: center; width: 36px; height: 36px;
  background: color-mix(in srgb, var(--accent) 14%, var(--panel)); color: var(--accent);
  border: 2px solid color-mix(in srgb, var(--accent) 40%, var(--line));
}

/* ---------- Page heads ---------- */
.page-head { padding: 56px 0 24px; }
.page-head h1 { font-size: clamp(2.2rem, 6vw, 3.4rem); letter-spacing: -.02em; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 60ch; }

/* ---------- Character sheet ---------- */
.sheet { display: grid; grid-template-columns: 340px 1fr; gap: 20px; padding-top: 40px; align-items: start; }
.sheet-side, .sheet-main { display: grid; gap: 20px; }
.sheet-side { position: sticky; top: 84px; }
.card { text-align: center; }
.portrait {
  width: 128px; height: 128px; margin: 4px auto 16px; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--accent) 22%, var(--panel-2)), var(--panel-2) 70%);
  border: 2px solid var(--line-2);
}
.portrait img { image-rendering: pixelated; }
.card-name { font-size: 1.6rem; margin-bottom: 2px; }
.card-class { color: var(--accent); font-weight: 500; margin-bottom: 18px; }
.stats { margin: 0 0 18px; text-align: left; border-top: 2px dashed var(--line); }
.stats div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 2px dashed var(--line); font-size: .92rem; }
.stats dt { font: .72rem var(--f-px); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding-top: 3px; }
.stats dd { margin: 0; text-align: right; }
.card-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 14px; }
.card-links { font-size: .9rem; margin: 0; }
.inv-cat { font-size: .78rem; color: var(--muted); font-weight: 500; margin: 14px 0 8px; }
.inv-cat:first-of-type { margin-top: 0; }
.inv { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.inv li {
  font: .82rem var(--f-mono); padding: 5px 9px;
  background: var(--panel-2); border: 2px solid var(--line);
  border-bottom-color: var(--line-2);
}
.timeline { list-style: none; margin: 0; padding: 0 0 0 22px; border-left: 2px solid var(--line); }
.tl-item { position: relative; padding: 0 0 26px 4px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -31px; top: 5px; width: 14px; height: 14px;
  background: var(--panel); border: 2px solid var(--line-2);
}
.tl-item.is-current::before { background: var(--xp); border-color: var(--xp); box-shadow: 0 0 0 4px color-mix(in srgb, var(--xp) 25%, transparent); }
.tl-head h3 { margin-bottom: 2px; }
.tl-meta { font: .8rem var(--f-mono); color: var(--muted); margin-bottom: 8px; }
.badge { font: .7rem var(--f-px); text-transform: uppercase; color: var(--xp); border: 1px solid var(--xp); padding: 1px 6px; margin-right: 4px; }
.tl-details { margin: 0 0 8px; padding-left: 18px; }
.tl-details li { margin-bottom: 4px; }
.tl-details li::marker { content: "› "; color: var(--accent); }
.loot { font: .82rem var(--f-mono); color: var(--muted); margin: 0; }
.loot .px { color: var(--mp); font-size: .7rem; margin-right: 6px; }
.training { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.training > li { background: var(--panel-2); border: 2px solid var(--line); padding: 16px; }
.training h3 { margin-bottom: 4px; }
.training .muted { font-size: .9rem; margin-bottom: 8px; }
.grade { margin: 0; font: 600 1.05rem var(--f-mono); }
.edu-notes { margin: 10px 0 0; padding-left: 18px; font-size: .9rem; color: var(--muted); }
.edu-notes li::marker { content: "› "; color: var(--accent); }
.side-quest + .side-quest { margin-top: 22px; padding-top: 18px; border-top: 2px dashed var(--line); }
.side-quest p:last-child { margin-bottom: 0; }
.grade .px { font: .7rem var(--f-px); color: var(--xp); margin-right: 6px; }

/* ---------- Quests ---------- */
.quests { display: grid; gap: 20px; }
.quest { display: grid; grid-template-columns: 280px 1fr; gap: 24px; align-items: center; }
.quest-art { display: block; background: #fff; border: 2px solid var(--line); aspect-ratio: 4 / 3; overflow: hidden; }
.quest-art img { width: 100%; height: 100%; object-fit: contain; padding: 10px; transition: transform .2s; }
.quest:hover .quest-art img { transform: scale(1.03); }
.quest h3 { font-size: 1.35rem; }
.quest h3 a { text-decoration: none; }
.quest-status { font-size: .7rem; color: var(--xp); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; background: currentColor; display: inline-block; }
.tags { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { font: .75rem var(--f-mono); color: var(--muted); border: 1px solid var(--line-2); padding: 2px 8px; }
.quest-rewards { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0; font-weight: 500; }
.page-head .quest-rewards { gap: 12px; margin-top: 20px; }
.side-quests { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.side-quests .panel { padding: 0; transition: border-color .1s; }
.side-quests .panel:hover { border-color: var(--accent); }
.side-quests a { display: grid; grid-template-rows: auto 1fr auto; gap: 6px; height: 100%; padding: 18px 20px; text-decoration: none; }
.sq-name { font: 600 1rem var(--f-mono); }
.side-quests a:hover .sq-name { color: var(--accent); }
.sq-desc { color: var(--muted); font-size: .93rem; line-height: 1.5; }
.sq-lang { font-size: .8rem; display: flex; align-items: center; gap: 6px; }
.sq-lang::before { content: ""; width: 10px; height: 10px; background: var(--muted); }
.sq-lang[data-lang="Python"]::before { background: #3f7cc4; }
.sq-lang[data-lang="JavaScript"]::before { background: #e3c84b; }
.sq-lang[data-lang="TypeScript"]::before { background: #3a8fd6; }

/* ---------- Journal ---------- */
.entries { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.entry { display: grid; grid-template-columns: 64px 1fr; gap: 16px; text-decoration: none; transition: border-color .1s; }
.entry:hover { border-color: var(--accent); color: var(--text); }
.entry-no { font-size: .9rem; color: var(--accent); padding-top: 3px; }
.entry-body { display: grid; gap: 4px; }
.entry-meta { font: .78rem var(--f-mono); color: var(--muted); }
.entry-title { font-size: 1.3rem; font-weight: 600; line-height: 1.25; }
.entry:hover .entry-title { color: var(--accent); }
.entry-desc { color: var(--muted); }

/* ---------- Post ---------- */
.read-xp { position: fixed; left: 0; right: 0; top: 0; height: 3px; z-index: 6; }
.read-xp span { display: block; height: 100%; width: 0; background: var(--xp); box-shadow: 0 0 8px var(--xp); }
.post-meta { font: .85rem var(--f-mono); color: var(--muted); }
.prose { font-size: 1.05rem; }
.prose h2, .prose h3, .prose h4 { margin: 2em 0 .6em; }
.prose h3 { font-size: 1.4rem; }
.prose h4 { font-size: 1.15rem; }
.prose h2::before, .prose h3::before { content: "§ "; color: var(--accent); font-weight: 400; }
.prose li { margin-bottom: .3em; }
.prose figure { margin: 2em 0; text-align: center; }
.prose figure img { background: #fff; padding: 12px; border: 2px solid var(--line); }
.prose figcaption { font-size: .88rem; color: var(--muted); margin-top: 8px; }
.prose iframe { width: 100%; height: auto; aspect-ratio: 960 / 569; border: 2px solid var(--line); }
.prose code { font: .88em var(--f-mono); background: var(--code-bg); border: 1px solid var(--line); padding: .1em .35em; }
.prose strong { color: color-mix(in srgb, var(--text) 85%, var(--accent)); }
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 56px; }
.post-nav a { display: grid; gap: 4px; text-decoration: none; font-weight: 600; }
.post-nav a:hover { border-color: var(--accent); }
.post-nav .px { font-size: .7rem; color: var(--muted); font-weight: 400; }
.post-nav .next { text-align: right; }
.post-nav-back { margin-top: 48px; }

/* Code — Prism tokens */
pre[class*="language-"] {
  font: .86rem/1.6 var(--f-mono); background: var(--code-bg);
  border: 2px solid var(--line); border-left: 4px solid var(--accent);
  padding: 16px 18px; overflow-x: auto; margin: 1.4em 0; tab-size: 4;
}
pre[class*="language-"] code { background: none; border: 0; padding: 0; font-size: inherit; }
.token.comment { color: var(--muted); font-style: italic; }
.token.keyword, .token.boolean { color: #c792ea; }
.token.string { color: var(--xp); }
.token.function { color: var(--mp); }
.token.number { color: var(--accent); }
.token.class-name { color: #ffcb6b; }
.token.operator, .token.punctuation { color: color-mix(in srgb, var(--text) 70%, var(--muted)); }
@media (prefers-color-scheme: light) {
  .token.keyword, .token.boolean { color: #7a3fb0; }
  .token.class-name { color: #9a6200; }
}

/* ---------- 404 ---------- */
.lost { padding-top: 72px; }

/* ---------- Footer ---------- */
.save { border-top: 2px solid var(--line); background: var(--bg-2); }
.save-inner { width: min(1120px, 100% - 32px); margin: 0 auto; padding: 36px 0 28px; }
.save-title { font-size: .85rem; color: var(--accent); margin-bottom: 6px; }
.save-icon { display: inline-block; animation: spin 2.4s steps(8) infinite; }
@keyframes spin { to { transform: rotateY(360deg); } }
.save-text { color: var(--muted); }
.save-links { list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 24px; font-weight: 500; }
.save-fine { font: .78rem var(--f-mono); color: var(--muted); margin: 0; }
.secret-hint { opacity: .35; letter-spacing: .1em; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 2px solid var(--accent); padding: 12px 18px;
  box-shadow: var(--shadow); max-width: calc(100% - 32px);
  animation: toast-in .25s steps(4);
}
.toast[hidden] { display: none; }
.toast b { font: .72rem var(--f-px); text-transform: uppercase; color: var(--accent); display: block; }
@keyframes toast-in { from { transform: translate(-50%, 24px); opacity: 0; } }

/* ---------- Secret CRT mode ---------- */
.crt body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 30;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, .18) 2px 3px);
  box-shadow: inset 0 0 140px rgba(0, 0, 0, .55);
}
.crt h1, .crt h2, .crt h3, .crt .menu-label, .crt .entry-title, .crt .latest-title, .crt .hud-name {
  font-family: var(--f-px); font-weight: 400; letter-spacing: 0;
}
.crt .title { font-size: clamp(2.4rem, 9vw, 6rem); line-height: 1.05; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sheet { grid-template-columns: 1fr; }
  .sheet-side { position: static; }
  .side-quests { grid-template-columns: 1fr 1fr; }
  .quest { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  body { font-size: 16px; }
  .hud { flex-direction: column; align-items: stretch; gap: 8px; padding-block: 8px; }
  .hud-nav { justify-content: space-between; }
  .hud-nav a { padding: 6px 8px; font-size: .88rem; gap: 6px; }
  .hud-nav kbd { display: none; }
  .title-screen { padding-top: 40px; }
  .menu-help { display: none; }
  .menu a { flex-direction: column; }
  .home-grid, .training, .side-quests, .post-nav { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .entry { grid-template-columns: 1fr; gap: 4px; }
  .post-nav .next { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Print: a plain, recruiter-friendly CV ---------- */
@media print {
  :root { --text: #000; --muted: #444; --line: #bbb; --line-2: #999; --panel: #fff; --panel-2: #fff; --accent: #000; --xp: #000; --mp: #000; }
  body { background: #fff; font-size: 11pt; line-height: 1.45; }
  .hud, .save, .toast, .card-actions, .read-xp, .portrait, .skip { display: none !important; }
  .crt body::after { display: none; }
  main { padding: 0; }
  .wrap { width: 100%; }
  .sheet { display: block; padding: 0; }
  .sheet-side, .sheet-main { display: block; position: static; }
  .panel { clip-path: none; border: 0; padding: 0 0 12pt; break-inside: avoid-page; }
  .card { text-align: left; }
  .stats { display: flex; flex-wrap: wrap; gap: 0 16pt; border: 0; }
  .stats div { border: 0; padding: 0; gap: 4pt; }
  .inv li { border: 0; padding: 0 6pt 0 0; background: none; }
  .inv li:not(:last-child)::after { content: ","; }
  .tl-item { break-inside: avoid; padding-bottom: 10pt; }
  .training li { border: 1px solid #ccc; }
  a { text-decoration: none; }
}
