:root {
  --console-grey: #dcd9d2;
  --console-grey-hi: #f0eee8;
  --console-grey-lo: #b6b2a9;
  --console-shadow: #6f6c64;
  --bezel-black: #17161a;
  --screen-bg: #0d0e14;
  --screen-bg-alt: #12141c;
  --nes-red: #e6001a;
  --nes-red-dark: #a4000f;
  --accent-blue: #2ea1ff;
  --accent-yellow: #ffce00;
  --accent-green: #35d67c;
  --text-light: #f2f2f0;
  --text-dim: #98a0ad;
  --font-pixel: "Press Start 2P", "VT323", monospace;
  --font-body: "VT323", "Press Start 2P", monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: #05050a radial-gradient(ellipse at 50% 20%, #14141c 0%, #05050a 70%);
  color: var(--text-light);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ============ CONSOLE SHELL ============ */
.console {
  width: 100%;
  max-width: 880px;
  background: linear-gradient(180deg, var(--console-grey-hi) 0%, var(--console-grey) 40%, var(--console-grey-lo) 100%);
  border-radius: 18px;
  box-shadow:
    0 30px 60px -20px rgba(0, 0, 0, 0.7),
    inset 0 2px 0 rgba(255, 255, 255, 0.5),
    inset 0 -6px 0 rgba(0, 0, 0, 0.15);
  padding: 18px 22px 22px;
  border: 1px solid var(--console-shadow);
}

/* -- top bar -- */
.console-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 16px;
  gap: 16px;
}

.vents {
  width: 90px;
  height: 18px;
  background-image: repeating-linear-gradient(
    90deg,
    var(--console-shadow) 0 3px,
    transparent 3px 8px
  );
  opacity: 0.6;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-pixel);
  white-space: nowrap;
}

.brand-name {
  color: var(--nes-red);
  font-size: 0.85rem;
  letter-spacing: 1px;
}

.brand-sub {
  font-size: 0.5rem;
  color: var(--console-shadow);
  letter-spacing: 1px;
}

.power-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--nes-red);
  box-shadow: 0 0 6px 2px rgba(230, 0, 26, 0.7);
  flex-shrink: 0;
  animation: led-pulse 2.4s ease-in-out infinite;
}

@keyframes led-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* -- body / screen bezel -- */
.console-body {
  background: linear-gradient(180deg, #cfccc4, #a9a69d);
  border-radius: 8px;
  padding: 4px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25);
}

.screen-bezel {
  background: var(--bezel-black);
  border-radius: 6px;
  padding: 18px;
  box-shadow: inset 0 0 0 2px #000, inset 0 10px 30px rgba(0, 0, 0, 0.8);
}

.screen {
  position: relative;
  background: var(--screen-bg);
  border-radius: 3px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  max-height: 70vh;
  animation: power-on 0.7s ease-out;
}

@keyframes power-on {
  0% { transform: scaleY(0.02); filter: brightness(3); opacity: 0.4; }
  40% { transform: scaleY(1); filter: brightness(3); opacity: 1; }
  100% { transform: scaleY(1); filter: brightness(1); opacity: 1; }
}

.scanlines {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.18) 0px,
    rgba(0, 0, 0, 0.18) 1px,
    transparent 2px,
    transparent 3px
  );
  mix-blend-mode: multiply;
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.75);
}

/* ============ GAME SCREENS ============ */
.game-screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: 28px 24px;
  overflow-y: auto;
}

.game-screen.active {
  display: flex;
}

.screen.flicker .game-screen.active {
  animation: flicker 0.25s steps(2, end);
}

@keyframes flicker {
  0% { opacity: 1; filter: brightness(1); }
  25% { opacity: 0.2; filter: brightness(3); }
  50% { opacity: 1; filter: brightness(0.6); }
  75% { opacity: 0.3; filter: brightness(2); }
  100% { opacity: 1; filter: brightness(1); }
}

/* -- boot screen -- */
.boot-content {
  margin: auto;
  text-align: center;
}

.game-title {
  font-family: var(--font-pixel);
  font-size: clamp(1.1rem, 4vw, 1.9rem);
  line-height: 1.5;
  color: var(--text-light);
  text-shadow: 3px 3px 0 var(--nes-red-dark);
  margin: 0 0 18px;
}

.game-subtitle {
  font-family: var(--font-body);
  font-size: clamp(1.1rem, 2.6vw, 1.5rem);
  color: var(--accent-blue);
  min-height: 1.4em;
  margin: 0 0 40px;
  letter-spacing: 1px;
}

.caret {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

.press-start {
  font-family: var(--font-pixel);
  font-size: clamp(0.7rem, 2vw, 0.95rem);
  color: var(--accent-yellow);
  animation: blink 1.1s step-end infinite;
  margin: 0 0 60px;
}

.copyright {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-dim);
  margin: 0;
}

/* -- menu / cartridge select -- */
#screen-menu {
  justify-content: center;
  align-items: center;
}

.menu-heading {
  font-family: var(--font-pixel);
  font-size: clamp(0.75rem, 2.2vw, 1rem);
  color: var(--text-light);
  margin: 0 0 36px;
  text-align: center;
}

.cartridge-grid {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.cartridge {
  position: relative;
  background: linear-gradient(180deg, #2a2c38, #1a1b23);
  border: 2px solid #3a3c4a;
  border-radius: 6px;
  padding: 22px 20px 16px;
  width: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.cartridge:hover,
.cartridge:focus-visible {
  transform: translateY(-6px);
  outline: none;
}

.cartridge.selected {
  border-color: var(--accent-yellow);
  box-shadow: 0 0 0 2px rgba(255, 206, 0, 0.35), 0 10px 24px -8px rgba(255, 206, 0, 0.4);
  transform: translateY(-6px);
}

.cart-icon {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-pixel);
  font-size: 1.3rem;
  color: #0d0e14;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25);
}

.icon-blue { background: var(--accent-blue); }
.icon-yellow { background: var(--accent-yellow); }
.icon-green { background: var(--accent-green); }

.cart-label {
  font-family: var(--font-pixel);
  font-size: 0.62rem;
  color: var(--text-light);
  text-align: center;
  letter-spacing: 0.5px;
}

.cart-select-arrow {
  position: absolute;
  left: -22px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent-yellow);
  font-size: 0.8rem;
  opacity: 0;
  animation: arrow-bounce 0.9s ease-in-out infinite;
}

.cartridge.selected .cart-select-arrow {
  opacity: 1;
}

@keyframes arrow-bounce {
  0%, 100% { transform: translateY(-50%) translateX(0); }
  50% { transform: translateY(-50%) translateX(4px); }
}

.menu-hint {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-dim);
  margin-top: 40px;
  text-align: center;
}

/* -- HUD (shared across content screens) -- */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 2px dashed #2a2c38;
  flex-wrap: wrap;
}

.hud-title {
  font-family: var(--font-pixel);
  font-size: clamp(0.7rem, 2vw, 0.95rem);
  color: var(--accent-yellow);
}

.hud-page {
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  color: var(--text-dim);
}

.back-btn {
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  color: var(--text-light);
  background: #23242e;
  border: 2px solid #3a3c4a;
  border-radius: 4px;
  padding: 8px 12px;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.back-btn:hover,
.back-btn:focus-visible {
  border-color: var(--accent-yellow);
  color: var(--accent-yellow);
}

.content-area {
  font-family: var(--font-body);
  font-size: 1.15rem;
  color: var(--text-light);
  flex: 1;
}

.section-lead {
  color: var(--text-dim);
  margin: 0 0 24px;
}

/* -- about -- */
.about-area {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 32px;
}

.dialog-box {
  background: var(--screen-bg-alt);
  border: 2px solid #2a2c38;
  border-radius: 6px;
  padding: 20px;
}

.dialog-box p {
  margin: 0 0 16px;
  color: var(--text-light);
}

.dialog-box p:last-child {
  margin-bottom: 0;
}

.dialog-box strong {
  color: var(--accent-blue);
}

.stat-heading {
  font-family: var(--font-pixel);
  font-size: 0.65rem;
  color: var(--accent-green);
  margin: 0 0 14px;
}

.stat-list {
  margin: 0 0 28px;
}

.stat-list li {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dotted #2a2c38;
}

.stat-key {
  color: var(--text-dim);
  letter-spacing: 1px;
}

.stat-val {
  color: var(--text-light);
  font-weight: 700;
}

.stat-val.glow {
  color: var(--accent-green);
  text-shadow: 0 0 8px rgba(53, 214, 124, 0.6);
}

.inventory-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inventory-list li {
  background: var(--screen-bg-alt);
  border: 1px solid #2a2c38;
  color: var(--accent-blue);
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 1rem;
}

/* -- projects -- */
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
}

.level-card {
  background: var(--screen-bg-alt);
  border: 2px solid #2a2c38;
  border-radius: 6px;
  padding: 18px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.level-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-yellow);
}

.level-tag {
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  color: #0d0e14;
  background: var(--accent-yellow);
  padding: 4px 8px;
  border-radius: 3px;
}

.level-card h3 {
  font-family: var(--font-pixel);
  font-size: 0.8rem;
  color: var(--text-light);
  margin: 14px 0 10px;
}

.level-card p {
  color: var(--text-dim);
  font-size: 1rem;
  margin: 0 0 16px;
}

.tech-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.tech-tags li {
  font-size: 0.9rem;
  color: var(--accent-green);
}

.level-links {
  display: flex;
  gap: 10px;
}

.pixel-btn {
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  color: #0d0e14;
  background: var(--accent-blue);
  padding: 8px 12px;
  border-radius: 3px;
  box-shadow: 0 3px 0 #1c6ba8;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  display: inline-block;
}

.pixel-btn:hover {
  transform: translateY(1px);
  box-shadow: 0 2px 0 #1c6ba8;
}

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

.pixel-btn.small {
  font-size: 0.55rem;
  padding: 7px 10px;
}

/* -- contact / controller -- */
.controller {
  margin: 20px auto 0;
  max-width: 480px;
  background: linear-gradient(180deg, #3a3c4a, #26272f);
  border: 2px solid #45475a;
  border-radius: 40px;
  padding: 30px 36px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 20px;
}

.controller-dpad {
  position: relative;
  width: 76px;
  height: 76px;
  justify-self: start;
}

.dpad-arm {
  position: absolute;
  background: #15161c;
  border-radius: 3px;
}

.dpad-vertical {
  width: 24px;
  height: 76px;
  left: 26px;
  top: 0;
}

.dpad-horizontal {
  width: 76px;
  height: 24px;
  left: 0;
  top: 26px;
}

.controller-ab {
  display: flex;
  gap: 14px;
  justify-self: end;
  transform: rotate(-18deg);
}

.ctrl-round-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--nes-red);
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 var(--nes-red-dark);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  position: relative;
}

.ctrl-round-btn:hover {
  transform: translateY(1px);
  box-shadow: 0 3px 0 var(--nes-red-dark);
}

.ctrl-round-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 var(--nes-red-dark);
}

.ctrl-round-btn::after {
  content: attr(data-label);
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-pixel);
  font-size: 0.5rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.controller-pills {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 18px;
}

.ctrl-pill {
  position: relative;
  width: 64px;
  height: 20px;
  border-radius: 12px;
  background: #15161c;
  color: var(--text-dim);
  font-family: var(--font-pixel);
  font-size: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-18deg);
  box-shadow: 0 3px 0 #000;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.ctrl-pill:hover {
  box-shadow: 0 2px 0 #000;
}

.ctrl-pill:active {
  box-shadow: 0 0 0 #000;
}

.ctrl-pill::after {
  content: attr(data-label);
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%) rotate(18deg);
  font-family: var(--font-pixel);
  font-size: 0.5rem;
  white-space: nowrap;
}

/* ============ CONSOLE BASE ============ */
.console-base {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px 4px;
  gap: 12px;
}

.port {
  width: 26px;
  height: 12px;
  background: var(--bezel-black);
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px #3a3c4a;
}

.reset-btn {
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  color: var(--console-shadow);
  background: linear-gradient(180deg, #efece6, #cfccc4);
  border: 1px solid var(--console-shadow);
  border-radius: 20px;
  padding: 8px 20px;
  box-shadow: 0 3px 0 var(--console-shadow);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.reset-btn:hover {
  color: var(--nes-red);
}

.reset-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--console-shadow);
}

.console-footer-text {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--console-shadow);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 700px) {
  body {
    padding: 12px 8px;
  }

  .console {
    border-radius: 10px;
    padding: 10px 10px 14px;
  }

  .vents,
  .brand-sub {
    display: none;
  }

  .console-top {
    padding: 4px 4px 10px;
  }

  .screen-bezel {
    padding: 8px;
  }

  .screen {
    aspect-ratio: auto;
    height: 78vh;
    max-height: none;
  }

  .game-screen {
    padding: 18px 14px;
  }

  .about-area {
    grid-template-columns: 1fr;
  }

  .cartridge-grid {
    gap: 14px;
  }

  .cartridge {
    width: 110px;
    padding: 16px 10px 12px;
  }

  .controller {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 24px 20px 34px;
  }

  .controller-dpad {
    justify-self: center;
  }

  .controller-ab {
    justify-self: center;
    transform: none;
  }

  .controller-pills {
    margin-top: 26px;
  }

  .ctrl-pill,
  .ctrl-pill::after {
    transform: none;
  }

  .console-footer-text {
    font-size: 0.8rem;
  }
}
