body {
  background-color: #212529;
  padding: 20px;
  font-family: "Press Start 2P", cursive;
  color: #fff;
}

#game-container {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

/* Section titles can be <h2> for structure; keep them visually identical
   (Press Start 2P has no bold, but guard against the fallback font). */
.nes-container.with-title > .title {
  font-weight: normal;
}

.nes-btn.is-primary {
  background-color: #e60012;
  color: #fff;
}

.hero-content {
  text-align: center;
  padding: 2rem 0;
}

.hero-content h1 {
  font-size: 1.5rem;
  margin: 2rem 0;
}

.animate {
  animation: bounce 0.5s infinite alternate;
}

@keyframes bounce {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-10px);
  }
}

.nes-input,
.nes-textarea {
  border-image-repeat: stretch;
  font-family: "Press Start 2P", cursive;
  font-size: 0.7rem;
}

.nes-btn.is-warning:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 0 #8a6d3b;
}

.nes-btn.is-warning {
  position: relative;
  background-color: #e60012;
  color: #fff;
  border: none;
  box-shadow:
    0 6px 0 #8a000b,
    0 8px 0 #000;
  transition: all 0.1s;
  text-transform: uppercase;
}

.nes-btn.is-warning:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #8a000b,
    0 4px 0 #000;
}

.game-over-screen {
  margin-top: 60px;
  padding-bottom: 40px;
}

.game-over-text {
  font-size: 2.5rem;
  color: #e60012;
  margin-bottom: 2rem;
  animation: flicker 2s infinite;
}

.continue-menu {
  display: inline-block;
  text-align: left;
  margin-bottom: 3rem;
}

.menu-option {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 1rem;
}

.menu-option a {
  color: #fff;
  text-decoration: none;
  font-size: 0.8rem;
}

.menu-option a:hover {
  color: #f7d51d;
}

.caret-right {
  animation: blink 0.8s infinite;
}

.transparent {
  opacity: 0;
}

.copyright-text {
  font-size: 0.5rem;
  color: #a0a0a0;
  line-height: 1.8;
}

@keyframes flicker {
  0%,
  18%,
  22%,
  25%,
  53%,
  57%,
  100% {
    opacity: 1;
  }
  20%,
  24%,
  55% {
    opacity: 0.7;
  }
}

@keyframes blink {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.8);
}

.quest-details {
  margin: 1.5rem 0;
  font-size: 0.7rem;
  line-height: 1.6;
}

.quest-details p {
  color: #f7d51d;
  margin-bottom: 1rem;
}

#dialog-contact {
  width: 90%;
  max-width: 500px;
  border-image-repeat: stretch;
}

#dialog-contact .nes-input,
#dialog-contact .nes-textarea {
  background-color: #fff;
  color: #212529;
}

.hero-content .nes-btn.is-primary {
  font-size: 1.2rem;
  padding: 1rem 2rem;
  margin-top: 2rem;
}

.pixel-avatar {
  width: 80px;
  height: auto;
  image-rendering: pixelated;
  margin-bottom: 20px;
}

@media (max-width: 600px) {
  .nes-list.is-disc {
    font-size: 0.6rem;
    line-height: 1.4;
    padding-left: 20px;
  }

  .nes-list.is-disc li {
    margin-bottom: 8px;
  }
  .nes-container.with-title > .title {
    font-size: 0.7rem;
  }
}

/* ===================================================================
   Feature 1: PRESS START boot screen
   =================================================================== */
#boot-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background-color: #000;
  text-align: center;
  cursor: pointer;
}

.boot-inner {
  animation: crt-power-on 1.1s ease-out both;
}

.boot-avatar {
  width: 64px;
  height: auto;
  image-rendering: pixelated;
  margin-bottom: 24px;
}

.boot-logo {
  font-size: 0.9rem;
  color: #a0a0a0;
  margin-bottom: 2.5rem;
}

.boot-press-start {
  font-size: 1.6rem;
  color: #fff;
  margin-bottom: 1.5rem;
  animation: boot-blink 1.1s steps(1, end) infinite;
}

.boot-hint {
  font-size: 0.6rem;
  color: #a0a0a0;
}

#boot-screen.is-dismissed {
  animation: crt-power-off 0.45s ease-in forwards;
  pointer-events: none;
}

@keyframes boot-blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@keyframes crt-power-on {
  0% {
    transform: scaleY(0.004);
    filter: brightness(4);
    opacity: 0;
  }
  35% {
    transform: scaleY(0.004);
    filter: brightness(4);
    opacity: 1;
  }
  55% {
    transform: scaleY(1);
    filter: brightness(2.2);
  }
  100% {
    transform: scaleY(1);
    filter: brightness(1);
    opacity: 1;
  }
}

@keyframes crt-power-off {
  0% {
    transform: scale(1, 1);
    filter: brightness(1);
    opacity: 1;
  }
  45% {
    transform: scale(1.05, 0.01);
    filter: brightness(5);
  }
  100% {
    transform: scale(0.6, 0.001);
    filter: brightness(10);
    opacity: 0;
  }
}

/* ===================================================================
   Feature 2: CRT scanline overlay
   =================================================================== */
#crt-overlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
  pointer-events: none;
  /* horizontal scanlines + faint RGB aperture grille */
  background:
    linear-gradient(
      rgba(18, 16, 16, 0) 50%,
      rgba(0, 0, 0, 0.25) 50%
    ),
    linear-gradient(
      90deg,
      rgba(255, 0, 0, 0.04),
      rgba(0, 255, 0, 0.02),
      rgba(0, 0, 255, 0.04)
    );
  background-size:
    100% 3px,
    4px 100%;
  /* vignette */
  box-shadow: inset 0 0 120px 20px rgba(0, 0, 0, 0.65);
  animation: crt-flicker 0.15s steps(2, end) infinite;
}

#crt-overlay.is-off {
  display: none;
}

@keyframes crt-flicker {
  0% {
    opacity: 0.9;
  }
  50% {
    opacity: 0.97;
  }
  100% {
    opacity: 0.92;
  }
}

/* ===================================================================
   Feature 2 + 3: control toggles (sound / CRT)
   =================================================================== */
.controls {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 9995;
  display: flex;
  gap: 8px;
}

.ctrl-btn {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Press Start 2P", cursive;
  font-size: 1rem;
  line-height: 1;
  color: #fff;
  background-color: #212529;
  border: 3px solid #fff;
  box-shadow: 0 4px 0 #000;
  cursor: pointer;
  transition: opacity 0.1s;
}

.ctrl-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #000;
}

.ctrl-btn[aria-pressed="false"] {
  opacity: 0.45;
}

@media (max-width: 600px) {
  /* Wrap instead of overflowing/overlapping the HUD on small phones */
  .controls {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 50vw;
  }
  .ctrl-btn {
    width: 40px;
    height: 40px;
    font-size: 0.85rem;
  }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  #crt-overlay {
    animation: none;
  }
  .boot-inner,
  #boot-screen.is-dismissed {
    animation: none;
  }
  .boot-press-start {
    animation: none;
    opacity: 1;
  }
  /* Calm the always-on decorative loops */
  .animate,
  .caret-right,
  .game-over-text {
    animation: none;
  }
}

/* ===================================================================
   Feature 5: Character sheet / skill stats
   =================================================================== */
.char-sheet {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: stretch;
}

.char-portrait {
  flex: 0 0 170px;
  align-self: flex-start;
  text-align: center;
  padding: 16px;
}

.char-avatar {
  width: 64px;
  height: auto;
  image-rendering: pixelated;
  margin-bottom: 14px;
}

.char-name {
  font-size: 1rem;
  margin-bottom: 6px;
}

.char-meta {
  font-size: 0.55rem;
  color: #f7d51d;
  margin-bottom: 18px;
}

.char-vitals {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vital {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vital-label {
  font-size: 0.6rem;
  width: 24px;
  text-align: left;
}

.char-stats {
  flex: 1 1 320px;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.char-about {
  margin-top: 22px;
  text-align: center;
}

.char-stats .stat {
  display: grid;
  grid-template-columns: 9.5rem 1fr 2.5rem;
  align-items: center;
  gap: 12px;
}

.stat-label {
  font-size: 0.55rem;
  line-height: 1.4;
}

.stat-num {
  font-size: 0.6rem;
  color: #f7d51d;
  text-align: right;
}

.char-stats .nes-progress,
.char-vitals .nes-progress {
  height: 24px;
  margin: 0;
}

@media (max-width: 600px) {
  .char-portrait {
    flex-basis: 100%;
  }
  .char-stats .stat {
    grid-template-columns: 1fr auto;
    gap: 4px 10px;
  }
  .char-stats .stat .nes-progress {
    grid-column: 1 / -1;
  }
  .stat-num {
    text-align: right;
  }
}

/* ===================================================================
   Bonus A: cartridge theme-swapper
   =================================================================== */
.cartridges {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 9995;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cartridge {
  position: relative;
  width: 56px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Press Start 2P", cursive;
  font-size: 0.5rem;
  color: #fff;
  background-color: #6b6b6b;
  border: 2px solid #000;
  border-top: 8px solid rgba(0, 0, 0, 0.45);
  box-shadow: 0 3px 0 #000;
  cursor: pointer;
}

.cartridge:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #000;
}

.cartridge[aria-pressed="true"] {
  outline: 3px solid #f7d51d;
  outline-offset: 2px;
}

.cart-gb {
  background-color: #6b8c42;
}

.cart-vb {
  background-color: #8c2a2a;
}

.cart-dev {
  background: linear-gradient(45deg, #e60012, #f7d51d, #22a0e6, #2ecc40);
  text-shadow: 0 0 2px #000;
}

@media (max-width: 600px) {
  .cartridges {
    flex-direction: row;
    top: auto;
    bottom: 12px;
    left: 12px;
  }
  .cartridge {
    width: 48px;
    height: 32px;
    font-size: 0.45rem;
  }
}

/* ===================================================================
   Cartridge palettes — recolor the whole "screen" via filter.
   Applied to content + dialogs only, so fixed chrome stays put.
   =================================================================== */
html[data-theme="gameboy"] #game-container,
html[data-theme="gameboy"] #skyline,
html[data-theme="gameboy"] dialog {
  filter: grayscale(1) sepia(0.7) hue-rotate(55deg) saturate(2.2)
    brightness(1.05) contrast(0.95);
}
html[data-theme="gameboy"] body {
  background-color: #0f380f;
}

html[data-theme="virtualboy"] #game-container,
html[data-theme="virtualboy"] #skyline,
html[data-theme="virtualboy"] dialog {
  filter: grayscale(1) sepia(1) hue-rotate(-40deg) saturate(6)
    brightness(0.78) contrast(1.3);
}
html[data-theme="virtualboy"] body {
  background-color: #1a0000;
}

html[data-theme="devmode"] #game-container,
html[data-theme="devmode"] #skyline,
html[data-theme="devmode"] dialog {
  animation: dev-rainbow 6s linear infinite;
}
html[data-theme="devmode"] body {
  background-color: #05010a;
}

@keyframes dev-rainbow {
  from {
    filter: hue-rotate(0deg) saturate(1.8);
  }
  to {
    filter: hue-rotate(360deg) saturate(1.8);
  }
}

@media (prefers-reduced-motion: reduce) {
  html[data-theme="devmode"] #game-container,
  html[data-theme="devmode"] dialog {
    animation: none;
    filter: invert(1) hue-rotate(180deg);
  }
}

/* ===================================================================
   Feature 4: Konami code FX — coin shower + toast
   =================================================================== */
#fx-layer {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  overflow: hidden;
}

.fx-coin {
  position: absolute;
  top: -48px;
  font-size: 1.6rem;
  animation-name: coin-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes coin-fall {
  0% {
    transform: translateY(-48px) rotate(0deg);
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0.9;
  }
}

.nes-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 160%);
  z-index: 9999;
  max-width: 90vw;
  padding: 14px 18px;
  font-family: "Press Start 2P", cursive;
  font-size: 0.6rem;
  line-height: 1.5;
  text-align: center;
  color: #212529;
  background-color: #f7d51d;
  border: 3px solid #000;
  box-shadow: 0 4px 0 #000;
  transition: transform 0.35s ease-out;
  pointer-events: none;
}

.nes-toast.show {
  transform: translate(-50%, 0);
}

/* ===================================================================
   Feature 9: score / coin HUD + collectible coins
   =================================================================== */
.hud {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9994;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 8px 14px;
  font-size: 0.6rem;
  color: #fff;
  background-color: rgba(0, 0, 0, 0.6);
  border: 2px solid #fff;
  white-space: nowrap;
}

.hud-item {
  display: inline-flex;
  align-items: center;
}

.hud-lives {
  color: #e60012;
  letter-spacing: 2px;
}

/* Draggable widgets (HUD, speedrun timer, terminal) */
.hud,
.speedrun,
.terminal-bar {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.hud:hover,
.speedrun:hover,
.terminal-bar:hover {
  outline: 1px dashed rgba(255, 255, 255, 0.4);
  outline-offset: 2px;
}

.hud.dragging,
.speedrun.dragging,
.terminal.dragging .terminal-bar {
  cursor: grabbing;
}

.hud.dragging,
.speedrun.dragging,
.terminal.dragging {
  opacity: 0.92;
}

.terminal-close {
  cursor: pointer;
}

.collectible {
  position: absolute;
  z-index: 5;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  filter: drop-shadow(0 0 4px rgba(247, 213, 29, 0.85));
  animation: coin-bob 0.8s ease-in-out infinite alternate;
}

.collectible:focus-visible {
  outline: 2px solid #f7d51d;
}

.collectible.collected {
  animation: coin-pop 0.45s ease-out forwards;
  pointer-events: none;
}

@keyframes coin-bob {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-6px);
  }
}

@keyframes coin-pop {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(2) translateY(-34px);
    opacity: 0;
  }
}

@media (max-width: 600px) {
  .hud {
    top: 8px;
    left: 8px;
    transform: none;
    gap: 8px;
    padding: 6px 8px;
    font-size: 0.45rem;
  }
}

/* ===================================================================
   Feature 8: achievements — trophy button badge + trophies dialog
   =================================================================== */
.trophy-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  font-family: "Press Start 2P", cursive;
  font-size: 0.4rem;
  line-height: 16px;
  text-align: center;
  color: #212529;
  background-color: #f7d51d;
  border: 2px solid #000;
  border-radius: 8px;
}

.trophy-list {
  list-style: none;
  margin: 1.2rem 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 52vh;
  overflow-y: auto;
}

.trophy {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.trophy-icon {
  flex: 0 0 auto;
  width: 1.6rem;
  font-size: 1.1rem;
  text-align: center;
}

.trophy-title {
  font-size: 0.6rem;
  color: #f7d51d;
  margin-bottom: 5px;
}

.trophy-desc {
  font-size: 0.55rem;
  line-height: 1.5;
  color: #fff;
}

.trophy.locked {
  opacity: 0.5;
}

.trophy.locked .trophy-title {
  color: #aaa;
}

/* ===================================================================
   Feature 7: RPG dialogue-box intro
   =================================================================== */
.intro-dialogue {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 9994;
  width: min(720px, 92vw);
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 18px 20px;
  color: #fff;
  background-color: #212529;
  border: 4px solid #fff;
  border-radius: 8px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.6);
  cursor: pointer;
}

.intro-avatar {
  flex: 0 0 auto;
  width: 48px;
  height: auto;
  image-rendering: pixelated;
  animation: bounce 0.5s infinite alternate;
}

.intro-body {
  flex: 1 1 auto;
}

.intro-name {
  font-size: 0.7rem;
  color: #f7d51d;
  margin-bottom: 10px;
}

.intro-text {
  font-size: 0.65rem;
  line-height: 1.7;
  min-height: 3.4em;
}

.intro-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.intro-skip {
  font-family: "Press Start 2P", cursive;
  font-size: 0.5rem;
  color: #a0a0a0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.intro-skip:hover {
  color: #fff;
}

.intro-next {
  font-size: 0.8rem;
  color: #f7d51d;
  animation: blink 0.8s steps(1) infinite;
}

.intro-next.is-hidden {
  visibility: hidden;
}

@media (max-width: 600px) {
  .intro-dialogue {
    bottom: 12px;
    gap: 10px;
    padding: 14px;
  }
  .intro-avatar {
    width: 36px;
  }
  .intro-text {
    font-size: 0.55rem;
  }
}

/* Reduced motion: calm the new looping animations */
@media (prefers-reduced-motion: reduce) {
  .collectible,
  .intro-avatar,
  .intro-next {
    animation: none;
  }
  .intro-next.is-hidden {
    visibility: hidden;
  }
}

/* ===================================================================
   Feature 11: pause menu
   =================================================================== */
.pause-menu {
  position: fixed;
  inset: 0;
  z-index: 9996;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background-color: rgba(0, 0, 0, 0.82);
}

.pause-panel {
  width: min(360px, 92vw);
  padding: 26px;
  text-align: left;
}

.pause-title {
  font-size: 1.2rem;
  text-align: center;
  letter-spacing: 2px;
  margin-bottom: 24px;
}

.pause-options {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pause-opt {
  width: 100%;
  padding: 4px 0;
  text-align: left;
  font-family: "Press Start 2P", cursive;
  font-size: 0.7rem;
  color: #fff;
  background: none;
  border: none;
  cursor: pointer;
}

.pause-opt .caret {
  margin-right: 8px;
  color: transparent;
}

.pause-opt:hover,
.pause-opt:focus {
  color: #f7d51d;
}

.pause-opt:hover .caret,
.pause-opt:focus .caret {
  color: #f7d51d;
}

.pause-suboptions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  padding-left: 24px;
}

.pause-sub {
  padding: 8px;
  text-align: left;
  font-family: "Press Start 2P", cursive;
  font-size: 0.55rem;
  color: #fff;
  background-color: #2a2f35;
  border: 2px solid #fff;
  cursor: pointer;
}

.pause-hint {
  margin-top: 22px;
  text-align: center;
  font-size: 0.5rem;
  color: #a0a0a0;
}

/* ===================================================================
   Feature 17: level-up banner
   =================================================================== */
.levelup-banner {
  position: fixed;
  top: 38%;
  left: 50%;
  z-index: 9997;
  padding: 16px 28px;
  font-family: "Press Start 2P", cursive;
  font-size: 1.4rem;
  color: #f7d51d;
  text-shadow: 3px 3px 0 #000;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%);
}

.levelup-banner.show {
  animation: levelup-pop 1.6s ease-out forwards;
}

@keyframes levelup-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }
  30% {
    transform: translate(-50%, -50%) scale(1);
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* ===================================================================
   Bonus B: speedrun timer
   =================================================================== */
.speedrun {
  position: fixed;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9994;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 4px 10px;
  font-size: 0.5rem;
  color: #fff;
  background-color: rgba(0, 0, 0, 0.5);
  border: 2px solid #555;
  white-space: nowrap;
}

.speedrun-pb {
  color: #a0a0a0;
}

@media (max-width: 600px) {
  .speedrun {
    top: 42px;
    left: 8px;
    transform: none;
    font-size: 0.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .levelup-banner.show {
    animation: levelup-fade 1.6s steps(1, end) forwards;
  }
  @keyframes levelup-fade {
    0% { opacity: 1; }
    100% { opacity: 0; }
  }
}

/* ===================================================================
   Feature 15: parallax Omaha skyline + real-time day/night
   =================================================================== */
.skyline {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.skyline .sky {
  position: absolute;
  inset: 0;
  transition: background 1.5s ease;
}

.skyline[data-phase="day"] .sky {
  background: linear-gradient(#5bc0eb 0%, #9fe7ff 70%, #cdeffd 100%);
}
.skyline[data-phase="dawn"] .sky {
  background: linear-gradient(#2a2a5a 0%, #c96b86 60%, #f3b06b 100%);
}
.skyline[data-phase="sunset"] .sky {
  background: linear-gradient(#21184a 0%, #6a2c70 45%, #e8763a 100%);
}
.skyline[data-phase="night"] .sky {
  background: linear-gradient(#05060f 0%, #0d1b3a 70%, #14254d 100%);
}

.skyline .stars {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1.5s ease;
  background-image:
    radial-gradient(1px 1px at 20% 30%, #fff, transparent),
    radial-gradient(1px 1px at 50% 15%, #fff, transparent),
    radial-gradient(1px 1px at 70% 38%, #fff, transparent),
    radial-gradient(1px 1px at 85% 18%, #fff, transparent),
    radial-gradient(1px 1px at 35% 48%, #fff, transparent),
    radial-gradient(1px 1px at 12% 58%, #fff, transparent),
    radial-gradient(1px 1px at 62% 24%, #fff, transparent),
    radial-gradient(1px 1px at 92% 52%, #fff, transparent),
    radial-gradient(1px 1px at 44% 8%, #fff, transparent);
  background-repeat: no-repeat;
}
.skyline[data-phase="night"] .stars,
.skyline[data-phase="sunset"] .stars {
  opacity: 1;
}

.skyline .celestial {
  position: absolute;
  width: 48px;
  height: 48px;
  top: 16%;
  right: 14%;
  border-radius: 50%;
  transition: all 1.5s ease;
}
.skyline[data-phase="day"] .celestial {
  background: #ffe66d;
  box-shadow: 0 0 40px 12px rgba(255, 230, 109, 0.6);
}
.skyline[data-phase="dawn"] .celestial {
  top: 42%;
  right: 70%;
  background: #ffd9a0;
  box-shadow: 0 0 30px 10px rgba(255, 200, 140, 0.5);
}
.skyline[data-phase="sunset"] .celestial {
  top: 48%;
  right: 12%;
  background: #ff8c42;
  box-shadow: 0 0 36px 12px rgba(255, 140, 66, 0.6);
}
.skyline[data-phase="night"] .celestial {
  background: #dfe6f0;
  box-shadow: 0 0 22px 6px rgba(223, 230, 240, 0.5);
}

.skyline .city {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42vh;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  will-change: transform;
}

.building {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), 1fr);
  gap: 4px;
  padding: 8px 5px;
  align-content: end;
  background: #0a0a14;
}
.skyline[data-phase="day"] .building {
  background: #3a4a63;
}
.skyline[data-phase="dawn"] .building {
  background: #2f2440;
}
.skyline[data-phase="sunset"] .building {
  background: #241836;
}

.window {
  width: 100%;
  aspect-ratio: 1 / 1.4;
  background: rgba(255, 255, 255, 0.05);
}
.window.lit {
  background: #ffd24a;
}
.skyline[data-phase="day"] .window.lit {
  background: rgba(255, 255, 255, 0.18);
}

@media (max-width: 600px) {
  .skyline .city {
    height: 30vh;
  }
  .skyline .celestial {
    width: 36px;
    height: 36px;
  }
}

/* ===================================================================
   Feature 14: hidden command-line terminal
   =================================================================== */
.terminal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 9996;
  width: min(640px, 94vw);
  height: min(420px, 80vh);
  display: flex;
  flex-direction: column;
  background: #0a0f0a;
  border: 3px solid #33ff66;
  box-shadow:
    0 0 0 3px #000,
    0 0 24px rgba(51, 255, 102, 0.3);
  font-family: "Courier New", Courier, monospace;
  color: #33ff66;
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #11331a;
  border-bottom: 2px solid #33ff66;
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #33ff66;
  opacity: 0.55;
}

.terminal-title {
  margin-left: 8px;
  font-size: 0.8rem;
}

.terminal-close {
  margin-left: auto;
  padding: 0 4px;
  font-size: 1.2rem;
  line-height: 1;
  color: #33ff66;
  background: none;
  border: none;
  cursor: pointer;
}

.terminal-output {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.terminal-output a {
  color: #7fffa0;
}

.terminal-inputline {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 2px solid #1f5f33;
}

.terminal-input {
  flex: 1 1 auto;
  background: transparent;
  border: none;
  outline: none;
  color: #33ff66;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.82rem;
}

.terminal-input::placeholder {
  color: #1f5f33;
}

/* ===================================================================
   Feature 6: world-map project select
   =================================================================== */
.world-map {
  position: relative;
  width: 100%;
  height: 280px;
  margin: 14px 0;
  overflow: hidden;
  background: linear-gradient(#1f4620 0%, #102a11 100%);
  border: 3px solid #000;
}

.map-path {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-path polyline {
  fill: none;
  stroke: #f7d51d;
  stroke-width: 1.2;
  stroke-dasharray: 3 3;
  opacity: 0.85;
}

.map-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: "Press Start 2P", cursive;
  color: #fff;
}

.node-star {
  font-size: 0.8rem;
  color: #f7d51d;
}

.node-flag {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-size: 0.6rem;
  background: #e60012;
  border: 3px solid #fff;
  border-radius: 50%;
}

.map-node-boss .node-flag {
  background: #8c2a2a;
  border-radius: 0;
}

.node-name {
  font-size: 0.5rem;
  white-space: nowrap;
  text-shadow: 1px 1px 0 #000;
}

.map-node:hover .node-flag,
.map-node:focus-visible .node-flag {
  outline: 3px solid #f7d51d;
  outline-offset: 2px;
}

.map-avatar {
  position: absolute;
  width: 38px;
  height: auto;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 3;
  transform: translate(-50%, -92%);
  transition:
    left 0.5s steps(6, end),
    top 0.5s steps(6, end);
}

.map-avatar.walking {
  animation: avatar-bob 0.18s steps(2, end) infinite;
}

@keyframes avatar-bob {
  from {
    transform: translate(-50%, -92%);
  }
  to {
    transform: translate(-50%, -98%);
  }
}

.map-hint {
  margin-top: 8px;
  text-align: center;
  font-size: 0.5rem;
  color: #a0a0a0;
}

/* ===================================================================
   Feature 10: boss battle
   =================================================================== */
.boss-battle {
  position: fixed;
  inset: 0;
  z-index: 9997;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background-color: rgba(0, 0, 0, 0.86);
}

.boss-panel {
  width: min(460px, 94vw);
  padding: 22px;
  text-align: center;
}

.boss-title {
  font-size: 0.7rem;
  color: #e60012;
  margin-bottom: 16px;
  line-height: 1.5;
}

.boss-arena {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.boss-enemy {
  font-size: 4rem;
  line-height: 1;
}

.boss-enemy.hit {
  animation: boss-shake 0.18s steps(2, end) 2;
  filter: brightness(2.2);
}

@keyframes boss-shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
  100% { transform: translateX(0); }
}

.boss-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  text-align: left;
}

.boss-bar-row {
  display: grid;
  grid-template-columns: 3rem 1fr;
  align-items: center;
  gap: 10px;
  font-size: 0.55rem;
}

.boss-bar-row .nes-progress {
  height: 22px;
  margin: 0;
}

.boss-timer {
  font-size: 0.6rem;
  margin-bottom: 10px;
}

.boss-msg {
  min-height: 2.4em;
  margin-bottom: 16px;
  font-size: 0.55rem;
  line-height: 1.5;
  color: #f7d51d;
}

.boss-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 0;
  padding: 0;
}

.boss-battle.shake .boss-panel {
  animation: boss-shake 0.2s steps(2, end) 2;
}

@media (prefers-reduced-motion: reduce) {
  .map-avatar,
  .map-avatar.walking,
  .boss-enemy.hit,
  .boss-battle.shake .boss-panel {
    animation: none;
    transition: none;
  }
}
