/* ==========================================================================
   Constantin Koehler · pixel site
   Colors are tokens on :root; night mode swaps them.
   ========================================================================== */

:root {
  --bg: #f3ead7;
  --grid: rgba(31, 24, 48, 0.05);
  --panel: #fffaf0;
  --panel-alt: #f6ecd6;
  --text: #1f1830;
  --muted: #625775;
  --line: #1f1830;
  --shadow: #1f1830;
  --accent: #c8412b;
  --accent-text: #fffaf0;
  --gold: #f6c445;
  --green: #2f7d3a;
  --navy: #3d5677;
  --focus: #2f6fe0;
  --hud: #1f1830;
  --hud-text: #f3ead7;
  --hero-sky: #86bff0;
  --show-day: none;
  --show-night: block;

  --ink: #1f1830;
  --cream: #fffaf0;
  --font-pixel: "Press Start 2P", ui-monospace, Menlo, monospace;
  --font-body: "Pixelify Sans", ui-rounded, system-ui, sans-serif;
  --hud-h: 52px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #13142a;
  --grid: rgba(255, 255, 255, 0.035);
  --panel: #1f2142;
  --panel-alt: #272a52;
  --text: #f0e9d8;
  --muted: #aba6ca;
  --line: #5a5f9e;
  --shadow: #07081a;
  --accent: #c8412b;
  --focus: #ffd34d;
  --hero-sky: #1c2257;
  --show-day: block;
  --show-night: none;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #13142a;
    --grid: rgba(255, 255, 255, 0.035);
    --panel: #1f2142;
    --panel-alt: #272a52;
    --text: #f0e9d8;
    --muted: #aba6ca;
    --line: #5a5f9e;
    --shadow: #07081a;
    --accent: #c8412b;
    --focus: #ffd34d;
    --hero-sky: #1c2257;
    --show-day: block;
    --show-night: none;
    color-scheme: dark;
  }
}

/* ---------- base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 2px, transparent 2px),
    linear-gradient(90deg, var(--grid) 2px, transparent 2px);
  background-size: 32px 32px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 19px;
  line-height: 1.5;
}

img {
  image-rendering: pixelated;
}

a {
  color: inherit;
}

strong {
  font-weight: 700;
}

h1,
h2,
h3 {
  font-family: var(--font-pixel);
  font-weight: 400;
  text-transform: uppercase;
}

[id] {
  scroll-margin-top: calc(var(--hud-h) + 16px);
}

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

.muted {
  color: var(--muted);
}

.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;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: -80px;
  z-index: 100;
  padding: 12px 16px;
  background: var(--gold);
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: 11px;
  text-decoration: none;
}

.skip-link:focus {
  top: calc(var(--hud-h) + 12px);
}

.blink {
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes bob {
  50% {
    transform: translateY(-4px);
  }
}

/* ---------- pixel frame: notched corners + hard drop shadow ---------- */

.panel {
  position: relative;
  margin: 4px;
  background: var(--panel);
  box-shadow:
    -4px 0 0 0 var(--line),
    4px 0 0 0 var(--line),
    0 -4px 0 0 var(--line),
    0 4px 0 0 var(--line),
    10px 6px 0 0 var(--shadow),
    6px 10px 0 0 var(--shadow),
    6px 6px 0 0 var(--shadow);
}

.label {
  margin: 0 0 10px;
  color: var(--muted);
  font-family: var(--font-pixel);
  font-size: 10px;
  line-height: 1.6;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- buttons ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 28px;
}

.btn {
  --btn-bg: var(--panel);
  --btn-text: var(--text);
  --btn-edge: var(--line);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 4px;
  padding: 15px 18px;
  border: 0;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1.2;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    -4px 0 0 0 var(--btn-edge),
    4px 0 0 0 var(--btn-edge),
    0 -4px 0 0 var(--btn-edge),
    0 4px 0 0 var(--btn-edge),
    inset -4px -4px 0 0 rgba(0, 0, 0, 0.2),
    inset 4px 4px 0 0 rgba(255, 255, 255, 0.28);
  transition: transform 90ms steps(2);
}

.btn:hover {
  transform: translateY(-3px);
}

.btn:active {
  transform: translateY(2px);
  box-shadow:
    -4px 0 0 0 var(--btn-edge),
    4px 0 0 0 var(--btn-edge),
    0 -4px 0 0 var(--btn-edge),
    0 4px 0 0 var(--btn-edge),
    inset 4px 4px 0 0 rgba(0, 0, 0, 0.2);
}

.btn-primary {
  --btn-bg: var(--accent);
  --btn-text: var(--accent-text);
}

.btn-primary::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 8px solid currentColor;
  animation: blink 1s steps(1) infinite;
}

/* ---------- HUD ---------- */

.hud {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--hud-h);
  padding: 0 16px;
  background: var(--hud);
  color: var(--hud-text);
  font-family: var(--font-pixel);
  font-size: 10px;
  text-transform: uppercase;
  box-shadow: 0 4px 0 0 rgba(0, 0, 0, 0.3);
}

.hud a {
  text-decoration: none;
}

.hud-brand {
  display: inline-flex;
  gap: 10px;
  white-space: nowrap;
}

.hud-1up {
  color: var(--gold);
}

.hud-nav {
  display: flex;
  gap: 22px;
}

.hud-nav a {
  position: relative;
  padding: 8px 0;
}

.hud-nav a::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  margin-top: -5px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 6px solid var(--gold);
  opacity: 0;
}

.hud-nav a:hover,
.hud-nav a[aria-current="true"] {
  color: var(--gold);
}

.hud-nav a:hover::before,
.hud-nav a[aria-current="true"]::before {
  opacity: 1;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hud-coins {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.hud-coins.bump {
  animation: bob 0.3s steps(2);
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 32px;
  padding: 0;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  box-shadow:
    -2px 0 0 0 var(--hud-text),
    2px 0 0 0 var(--hud-text),
    0 -2px 0 0 var(--hud-text),
    0 2px 0 0 var(--hud-text);
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.18);
}

.icon-sun {
  display: var(--show-day);
}

.icon-moon {
  display: var(--show-night);
}

@media (max-width: 860px) {
  .hud-nav {
    display: none;
  }
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  display: flex;
  min-height: 100vh;
  min-height: 100svh;
  padding: 0 16px;
  overflow: hidden;
  background: var(--hero-sky);
  isolation: isolate;
}

.hero-scene {
  position: absolute;
  left: 0;
  top: 0;
  z-index: -1;
  image-rendering: pixelated;
}

.hero-content {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding-top: calc(var(--hud-h) + clamp(28px, 7vh, 88px));
  padding-bottom: calc(var(--ground, 25svh) + var(--clear, 96px));
}

.eyebrow {
  display: inline-flex;
  gap: 10px;
  margin: 0;
  padding: 9px 12px;
  background: var(--ink);
  color: var(--gold);
  font-family: var(--font-pixel);
  font-size: 11px;
  text-transform: uppercase;
}

.hero h1 {
  margin: 20px 0 26px;
  color: var(--cream);
  font-size: clamp(28px, 6.2vw, 64px);
  line-height: 1.15;
  text-shadow:
    4px 4px 0 var(--ink),
    -2px -2px 0 var(--ink),
    2px -2px 0 var(--ink),
    -2px 2px 0 var(--ink);
}

.dialog {
  max-width: 560px;
  margin: 4px;
  padding: 18px 20px;
  background: var(--ink);
  color: var(--cream);
  box-shadow:
    -4px 0 0 0 var(--cream),
    4px 0 0 0 var(--cream),
    0 -4px 0 0 var(--cream),
    0 4px 0 0 var(--cream),
    -8px 0 0 0 var(--ink),
    8px 0 0 0 var(--ink),
    0 -8px 0 0 var(--ink),
    0 8px 0 0 var(--ink);
}

.dialog p {
  margin: 0;
}

.dialog-role {
  font-family: var(--font-pixel);
  font-size: clamp(11px, 2.2vw, 15px);
  line-height: 1.8;
  text-transform: uppercase;
}

.numo-link {
  color: var(--gold);
  text-transform: none;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.numo-link:hover {
  background: var(--gold);
  color: var(--ink);
  text-decoration: none;
}

.dialog-blurb {
  margin-top: 12px !important;
  font-size: 19px;
  line-height: 1.45;
}

.dialog-role .at {
  color: #b8b0d6;
}

.dialog-sub {
  margin-top: 10px !important;
  padding-top: 10px;
  border-top: 2px dashed rgba(255, 250, 240, 0.25);
  color: #cfc8e6;
  font-size: 17px;
}

.hero .btn {
  --btn-edge: var(--ink);
}

.hero .btn:not(.btn-primary) {
  --btn-bg: var(--cream);
  --btn-text: var(--ink);
}

.hero-player {
  position: absolute;
  z-index: 2;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.hero-tip {
  position: absolute;
  z-index: 2;
  margin: 0;
  padding: 7px 9px;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: 8px;
  line-height: 1.4;
  white-space: nowrap;
  text-transform: uppercase;
  transform: translate(-50%, -100%);
  box-shadow:
    -2px 0 0 0 var(--ink),
    2px 0 0 0 var(--ink),
    0 -2px 0 0 var(--ink),
    0 2px 0 0 var(--ink);
  pointer-events: none;
  visibility: hidden;
}

.hero-tip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  margin-left: -4px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid var(--ink);
}

.hero-tip.is-placed {
  visibility: visible;
  animation: bob 1.2s steps(2) infinite;
}

.hero-tip.is-done {
  display: none;
}

/* ---------- sections ---------- */

.section {
  max-width: 1120px;
  margin: 0 auto;
  padding: 104px 16px 0;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 36px;
}

.section-head::after {
  content: "";
  flex: 1;
  min-width: 24px;
  height: 4px;
  background: repeating-linear-gradient(90deg, var(--line) 0 8px, transparent 8px 16px);
}

.section-num {
  padding: 8px;
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-pixel);
  font-size: 11px;
}

.section-head h2 {
  margin: 0;
  font-size: clamp(17px, 3vw, 26px);
  line-height: 1.3;
}

/* ---------- profile ---------- */

.profile {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 44px;
  align-items: start;
}

.player-card {
  padding: 20px;
}

.portrait {
  margin-bottom: 18px;
  background: var(--navy);
  box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 0.18);
}

.portrait img {
  display: block;
  width: 100%;
  height: auto;
}

.stats {
  margin: 0;
}

.stats div {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  padding: 9px 0;
  border-top: 2px dashed var(--grid);
  border-top-color: color-mix(in srgb, var(--line) 30%, transparent);
}

.stats div:first-child {
  border-top: 0;
}

.stats dt {
  padding-top: 5px;
  color: var(--muted);
  font-family: var(--font-pixel);
  font-size: 9px;
  text-transform: uppercase;
}

.stats dd {
  margin: 0;
  font-weight: 600;
  line-height: 1.35;
}

.dialog-box {
  padding: 36px 30px 44px;
  font-size: 20px;
}

.dialog-box p {
  margin: 0 0 16px;
}

.dialog-box .speaker {
  position: absolute;
  top: -18px;
  left: 20px;
  margin: 0;
  padding: 9px 11px;
  background: var(--accent);
  color: var(--accent-text);
  font-family: var(--font-pixel);
  font-size: 11px;
  text-transform: uppercase;
  box-shadow:
    -4px 0 0 0 var(--line),
    4px 0 0 0 var(--line),
    0 -4px 0 0 var(--line),
    0 4px 0 0 var(--line);
}

.dialog-next {
  position: absolute;
  right: 22px;
  bottom: 14px;
  color: var(--accent);
  font-size: 14px;
  animation: bob 1s steps(2) infinite;
}

/* ---------- quest ---------- */

.quest {
  padding: 30px;
}

.quest-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.quest h3 {
  margin: 0 0 10px;
  font-size: clamp(14px, 2.4vw, 20px);
  line-height: 1.5;
}

.quest-guild {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  background: var(--green);
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 10px;
  text-transform: uppercase;
}

.quest-goal {
  margin: 26px 0 0;
  font-size: 20px;
}

.objectives {
  display: grid;
  gap: 14px;
  margin: 22px 0 26px;
  padding: 0;
  list-style: none;
}

.objectives li {
  position: relative;
  padding-left: 36px;
}

.objectives li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 7px;
  width: 12px;
  height: 12px;
  background: var(--gold);
  box-shadow:
    -3px 0 0 0 var(--line),
    3px 0 0 0 var(--line),
    0 -3px 0 0 var(--line),
    0 3px 0 0 var(--line);
}

.reward {
  margin: 0;
  padding-top: 20px;
  border-top: 4px dashed color-mix(in srgb, var(--line) 35%, transparent);
}

.reward .label {
  display: inline;
  margin-right: 10px;
  color: var(--accent);
}

/* ---------- inventory ---------- */

.items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 30px 28px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.item {
  padding: 22px 20px 24px;
}

.item img {
  display: block;
  box-sizing: content-box;
  width: 48px;
  height: 48px;
  margin-bottom: 18px;
  padding: 10px;
  object-fit: contain;
  background: var(--panel-alt);
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--line) 25%, transparent);
}

.item:hover img {
  animation: bob 0.6s steps(2) infinite;
}

.item h3 {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.5;
}

.item p {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.4;
}

/* ---------- world map ---------- */

.levels {
  position: relative;
  display: grid;
  gap: 26px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.level {
  position: relative;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 18px;
  align-items: start;
}

/* dashed path from each node down to the next one */
.level:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 30px;
  top: 64px;
  bottom: -26px;
  width: 4px;
  background: repeating-linear-gradient(to bottom, var(--line) 0 8px, transparent 8px 16px);
}

.brand {
  text-transform: none;
}

.node {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 4px;
  background: var(--panel);
  font-family: var(--font-pixel);
  font-size: 16px;
  box-shadow:
    -4px 0 0 0 var(--line),
    4px 0 0 0 var(--line),
    0 -4px 0 0 var(--line),
    0 4px 0 0 var(--line);
}

.level-current .node {
  background: var(--accent);
}

.level-current .node img {
  animation: bob 1s steps(2) infinite;
}

.level-tutorial .node {
  color: var(--muted);
}

.level-card {
  padding: 18px 22px;
}

.level-card h3 {
  margin: 0 0 6px;
  font-size: 14px;
  line-height: 1.5;
}

.level-card h3 .muted {
  font-size: 11px;
}

.level-card p {
  margin: 0 0 6px;
}

.level-card p:last-child {
  margin-bottom: 0;
}

.level-card .role {
  font-weight: 600;
}

.level-current .level-card {
  --line: var(--accent);
}

@media (min-width: 900px) {
  .levels {
    gap: 8px;
  }

  .level:not(:last-child)::before {
    left: 50%;
    margin-left: -2px;
    bottom: -8px;
  }

  .level {
    grid-template-columns: 1fr 64px 1fr;
    gap: 28px;
  }

  .level .node {
    grid-column: 2;
    grid-row: 1;
  }

  .level .level-card {
    grid-column: 3;
    grid-row: 1;
  }

  .level:nth-child(even) .level-card {
    grid-column: 1;
  }
}

/* ---------- contact ---------- */

.continue {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px 52px;
  text-align: center;
}

.continue-countdown {
  margin: 0 0 22px;
  color: var(--accent);
  font-family: var(--font-pixel);
  font-size: clamp(14px, 2.6vw, 20px);
  text-transform: uppercase;
}

.continue h2 {
  margin: 0 0 16px;
  font-size: clamp(18px, 3.4vw, 28px);
  line-height: 1.3;
}

.continue p {
  max-width: 34em;
  margin: 0 auto;
  font-size: 20px;
}

.continue .actions {
  justify-content: center;
}

/* ---------- footer + toast ---------- */

.footer {
  padding: 96px 16px 48px;
  color: var(--muted);
  font-family: var(--font-pixel);
  font-size: 9px;
  line-height: 2;
  text-align: center;
  text-transform: uppercase;
}

.footer p {
  margin: 0;
}

.footer-heart {
  display: inline-block;
  margin: 0 2px;
  vertical-align: -2px;
}

.footer-hint {
  margin-top: 6px !important;
  opacity: 0.6;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  letter-spacing: 0.25em;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  padding: 12px 16px;
  background: var(--ink);
  color: var(--gold);
  font-family: var(--font-pixel);
  font-size: 11px;
  text-transform: uppercase;
  transform: translate(-50%, 140%);
  visibility: hidden;
  transition: transform 160ms steps(3), visibility 0s 160ms;
  box-shadow:
    -4px 0 0 0 var(--cream),
    4px 0 0 0 var(--cream),
    0 -4px 0 0 var(--cream),
    0 4px 0 0 var(--cream);
}

.toast.show {
  transform: translate(-50%, 0);
  visibility: visible;
  transition: transform 160ms steps(3);
}

/* CRT mode (secret) */
.crt body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.14) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.35));
}

/* ---------- small screens ---------- */

@media (max-width: 820px) {
  .profile {
    grid-template-columns: 1fr;
    gap: 48px;
  }

  .player-card {
    max-width: 420px;
  }

  .dialog-box {
    padding: 34px 22px 40px;
    font-size: 19px;
  }

  .quest {
    padding: 24px 20px;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 18px;
  }

  .hud-name {
    display: none;
  }

  .section {
    padding-top: 88px;
  }

  .actions {
    gap: 14px;
  }

  .btn {
    padding: 14px 14px;
    font-size: 11px;
  }

  .stats div {
    grid-template-columns: 80px 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
