:root {
  --ink: #10202e;
  --paper: #f3efe4;
  --amber: #b8722c;
  --sky: #5c94fc;
  --white: #fff7e7;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Courier New", Courier, monospace;
}

button, a { font: inherit; }

.shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 36px) 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 14px;
}

.identity {
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(24px, 2.8vw, 30px);
  color: var(--ink);
  text-decoration: none;
  font-weight: 900;
  letter-spacing: .08em;
  line-height: 1;
}

.identity small {
  display: block;
  margin-top: 6px;
  color: var(--amber);
  font-size: 17px;
  letter-spacing: .06em;
}

.top-actions { display: flex; align-items: center; gap: 18px; }

.text-button {
  appearance: none;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 12px 0;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .04em;
}

.text-button:hover, .text-button:focus-visible { color: var(--amber); border-color: var(--amber); }

.game-frame {
  position: relative;
  overflow: hidden;
  border: 8px solid var(--ink);
  background: var(--sky);
  box-shadow: 10px 10px 0 var(--amber);
  aspect-ratio: 16 / 9;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(16, 32, 46, .68);
}

.overlay[hidden] { display: none; }

.panel {
  width: min(580px, 94%);
  background: var(--paper);
  border: 6px solid var(--ink);
  box-shadow: 8px 8px 0 #000;
  padding: clamp(24px, 4vw, 42px);
  text-align: center;
}

.eyebrow {
  margin: 0 0 15px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .12em;
}

.title-panel h1, .win-panel h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(40px, 7vw, 76px);
  line-height: .86;
  letter-spacing: -.08em;
  text-shadow: 4px 4px 0 #d8d2c2;
}

.title-panel h1 span, .win-panel h2 span { color: var(--amber); }

.mission {
  width: min(500px, 100%);
  margin: 18px auto 22px;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  font-size: 21px;
  line-height: 1.4;
}

.controls-copy { margin: 18px 0 0; font-size: 10px; font-weight: 800; }

.pixel-button {
  display: inline-block;
  appearance: none;
  border: 4px solid var(--ink);
  background: var(--amber);
  color: #fff;
  padding: 13px 20px;
  box-shadow: 5px 5px 0 var(--ink);
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .04em;
}

.pixel-button:hover, .pixel-button:focus-visible { transform: translate(2px, 2px); box-shadow: 3px 3px 0 var(--ink); }
.pixel-button.small { padding: 10px 16px; font-size: 12px; }
.pixel-button.secondary { background: var(--paper); color: var(--ink); }
.pixel-button:disabled { opacity: .65; cursor: default; transform: none; }

.fact-panel { width: min(740px, 96%); max-height: 100%; overflow-y: auto; padding: 22px 28px; }
.fact-icon {
  display: grid; place-items: center; width: 116px; height: 116px;
  margin: 0 auto 18px; border: 4px solid var(--ink);
  background: #f1d59d; color: var(--ink); box-shadow: 6px 6px 0 var(--amber);
  font-family: Arial, Helvetica, sans-serif; font-weight: 900; font-size: 64px; line-height: 1;
  animation: power-pop 360ms cubic-bezier(.2,.8,.3,1.25) both, power-pulse 3s ease-in-out 500ms infinite;
}
.fact-panel h2 { margin: 10px auto 14px; max-width: 610px; font-family: Arial, Helvetica, sans-serif; font-weight: 900; font-size: clamp(24px, 3vw, 32px); line-height: 1.12; text-wrap: balance; }
.fact-icon img { display: block; width: 88%; height: 88%; object-fit: contain; }
.fact-icon:has(img[src$=".png"]) { background: none; border: 0; box-shadow: none; }
.fact-icon img[src$=".png"] { width: 100%; height: 100%; }
.title-panel { width: min(700px, 96%); padding: 22px 30px; max-height: 100%; overflow-y: auto; }
.title-panel .eyebrow { font-family: Arial, Helvetica, sans-serif; font-size: 19px; color: #87501e; letter-spacing: .06em; margin-bottom: 14px; }
.version { font-size: 15px; margin-left: 8px; white-space: nowrap; }
.title-panel h1 { font-size: inherit; line-height: 1; text-shadow: none; }
.title-logo { display: block; width: min(460px, 100%); height: auto; margin: auto; }
.title-panel .pixel-button { font-family: Arial, Helvetica, sans-serif; font-size: 20px; padding: 12px 30px; }
.start-tagline { max-width: 440px; margin: 20px auto 0; font: 700 18px/1.4 Arial, Helvetica, sans-serif; color: #354757; }
@media (max-width: 760px) {
  .game-frame { min-height: 440px; }
  .top-actions { flex-wrap: wrap; gap: 10px 24px; }
  .title-panel { padding: 18px; }
  .title-logo { max-width: 350px; }
  .title-panel .eyebrow { font-size: 17px; }
  .mission { font-size: 19px; }
  .start-tagline { font-size: 17px; }
}
.fact-panel .eyebrow { font-size: 15px; color: #87501e; margin-bottom: 16px; }
.fact-panel .pixel-button.small { font-family: Arial, Helvetica, sans-serif; font-size: 16px; line-height: 1.3; min-height: 46px; }
@keyframes power-pop { from { opacity: 0; transform: scale(.72) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes power-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.fact-panel p:not(.eyebrow) { max-width: 560px; margin: 0 auto 24px; font-family: Arial, Helvetica, sans-serif; font-weight: 750; color: #10202e; font-size: clamp(18px, 2.1vw, 23px); line-height: 1.42; }
.fact-panel #factCopy strong { color: #87501e; }
.fact-story { display: block; margin-top: 18px; }

.win-panel p:not(.eyebrow) { max-width: 520px; margin: 24px auto; font-family: Arial, Helvetica, sans-serif; font-size: clamp(20px, 2.3vw, 25px); font-weight: 800; line-height: 1.45; color: #10202e; }
.win-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 15px; }

.hud {
  position: absolute;
  z-index: 2;
  top: 14px;
  left: 18px;
  right: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
  font-size: clamp(9px, 1.4vw, 14px);
  font-weight: 900;
  text-shadow: 2px 2px 0 #10202e;
  pointer-events: none;
}

.mobile-controls {
  position: absolute;
  z-index: 3;
  display: none;
  left: 14px;
  right: 14px;
  bottom: 12px;
  justify-content: space-between;
  pointer-events: none;
}

.mobile-controls div { display: flex; gap: 9px; }
.mobile-controls button {
  width: 54px;
  height: 50px;
  border: 3px solid rgba(255,255,255,.82);
  border-radius: 4px;
  background: rgba(16,32,46,.58);
  color: #fff;
  font-weight: 900;
  pointer-events: auto;
  touch-action: none;
}
.mobile-controls .jump { width: 76px; }

.footer-note {
  margin: 22px 0 0;
  text-align: center;
  color: #6b6558;
  font-size: 11px;
  font-weight: 700;
}

@media (pointer: coarse), (max-width: 760px) {
  canvas { object-fit: contain; }
  .mobile-controls { display: flex; }
  .topbar { flex-wrap: wrap; }
  .game-frame { border-width: 5px; box-shadow: 6px 6px 0 var(--amber); }
  .panel { border-width: 4px; box-shadow: 5px 5px 0 #000; padding: 20px; }
  .controls-copy { display: none; }
}

@media (max-width: 520px) {
  .game-frame { aspect-ratio: auto; height: 420px; }
  canvas { object-fit: contain; }
  .fact-panel { max-height: 95%; overflow-y: auto; }
  .shell { padding-inline: 8px; }
  .topbar { padding-inline: 6px; }
  .identity small { font-size: 16px; }
  .text-button { font-size: 16px; }
  .overlay { padding: 10px; }
  .mission { margin: 16px auto; }
  .pixel-button { padding: 10px 13px; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  .fact-icon { animation: none; }
}

@media (max-width: 760px) {
  .fact-screen { padding: 10px; }
  .fact-panel { padding: 16px; }
  .fact-icon { width: 88px; height: 88px; font-size: 48px; margin-bottom: 12px; }
  .fact-panel h2 { font-size: 24px; }
  .fact-panel .eyebrow { font-size: 14px; margin-bottom: 12px; }
  .fact-panel p:not(.eyebrow) { font-size: 19px; margin-bottom: 18px; }
}
