:root {
  --bg-dark: #000000;
  --bg-panel: #1a1a1a;
  --accent: #f2c14e;
  --text: #ffffff;
  --text-muted: #a8a8a8;
  --border-pixel: 4px solid #ffffff;
}

* {
  box-sizing: border-box;
  image-rendering: pixelated;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--text);
  font-family: 'Press Start 2P', monospace;
  background-color: #000;
}

body::after {
  content: " ";
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
  z-index: 200;
  background-size: 100% 2px, 3px 100%;
  pointer-events: none;
}

.game-shell {
  width: min(95vw, 1000px);
  padding: 1.5rem;
  background: var(--bg-panel);
  border: 4px solid #333;
  box-shadow: inset -4px -4px 0px 0px #000, inset 4px 4px 0px 0px #555;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  border-bottom: 4px solid #333;
  padding-bottom: 1rem;
}

h1 {
  margin: 0;
  font-size: 1.5rem;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.hud p {
  margin: 0;
  padding: 1rem;
  background: #000;
  border: 2px solid #444;
  font-size: 0.65rem;
  line-height: 1.5;
}

.hud span {
  display: block;
  color: var(--accent);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.hud strong {
  font-size: 0.8rem;
}

.quests {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.quest-box {
  padding: 1rem;
  background: #000;
  border: 2px solid #444;
}

.quest-box h2 {
  margin: 0 0 1rem;
  font-size: 0.7rem;
  color: var(--accent);
  text-transform: uppercase;
}

.quest-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.quest-list li {
  font-size: 0.6rem;
  padding: 0.5rem 0;
  color: #ccc;
}

.quest-list li.done {
  color: #8a8a8a;
  text-decoration: line-through;
}

.guide-note {
  font-size: 0.6rem;
  line-height: 1.6;
  color: #eee;
  margin: 0;
}

canvas {
  width: 100%;
  margin-bottom: 1.5rem;
  aspect-ratio: 16 / 9;
  border: 4px solid #fff;
  background: #000;
  image-rendering: pixelated;
  display: block;
}

.help {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Menu Overlay */
#game-menu {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border: 4px solid #fff;
}

.menu-title {
  font-size: clamp(1.6rem, 6.5vw, 4rem);
  line-height: 1.3;
  color: var(--accent);
  margin-bottom: clamp(1.5rem, 5vw, 3.5rem);
  text-shadow: 8px 8px 0px #222, 12px 12px 0px #000;
  text-align: center;
}

.menu-btn {
  background: none;
  border: none;
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.9rem, 3vw, 1.4rem);
  margin: clamp(0.5rem, 1.5vw, 1rem);
  cursor: pointer;
  text-decoration: none;
}

.menu-btn:hover {
  color: var(--accent);
}

.menu-btn::before {
  content: '> ';
  opacity: 0;
}

.menu-btn:hover::before {
  opacity: 1;
}

.menu-btn:active {
  transform: translate(4px, 4px);
  color: #fff;
}

.quest-box h2 span {
  color: #fff;
}

:focus-visible {
  outline: 4px solid var(--accent);
  outline-offset: 4px;
}

.menu-btn:focus-visible {
  color: var(--accent);
}

.credits {
  max-width: 34rem;
  margin: 1rem 1.5rem 0;
  font-size: 0.6rem;
  line-height: 1.8;
  text-align: center;
  color: #ddd;
}

.credits a,
.copyright a {
  color: inherit;
}

.copyright {
  margin: 0.75rem 0 0;
  text-align: center;
  font-size: 0.55rem;
  color: var(--text-muted);
}

/* Touch pad, only where there is no keyboard to rely on */
.dpad {
  display: none;
  grid-template-columns: repeat(3, 3.5rem);
  grid-template-rows: repeat(3, 3.5rem);
  justify-content: center;
  margin: 1rem 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.dpad button {
  background: #000;
  color: #fff;
  border: 2px solid #777;
  font-size: 1rem;
}

.dpad button:active {
  background: var(--accent);
  color: #000;
}

.dpad-up { grid-area: 1 / 2; }
.dpad-left { grid-area: 2 / 1; }
.dpad-right { grid-area: 2 / 3; }
.dpad-down { grid-area: 3 / 2; }

@media (pointer: coarse) {
  .dpad { display: grid; }
}

@media (max-width: 768px) {
  .game-shell { padding: 0.75rem; }
  .quests { margin-top: 1rem; }
  .help { line-height: 1.8; }
  .hud { grid-template-columns: repeat(2, 1fr); }
  .quests { grid-template-columns: 1fr; }
}
