/* ---- tokens: NES/arcade palette ---- */
:root{
  --black: #000000;
  --bg: #0f0a1e;
  --panel: #1a1030;
  --line: #3d2a5c;
  --grey: #8b7fae;
  --grey-dim: #4a3d6b;
  --white: #f4f1ff;
  --amber: #ffd400;
  --amber-dim: #5c4d00;
  --red: #ff3355;
  --cyan: #38e8e0;
  --green: #4ade5a;
  --pixel: 'Press Start 2P', monospace;
  --mono: 'VT323', monospace;
}

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

html{ scroll-behavior: smooth; }

body{
  margin: 0;
  background: var(--bg);
  color: var(--white);
  font-family: var(--mono);
  font-size: 19px;
  line-height: 1.5;
  position: relative;
  overflow-x: hidden;
}

/* ---- pixel grid background (perspective floor style) ---- */
.grid-overlay{
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(56,232,224,0.05) 2px, transparent 2px),
    linear-gradient(90deg, rgba(56,232,224,0.05) 2px, transparent 2px),
    linear-gradient(rgba(255,51,85,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,51,85,0.04) 1px, transparent 1px);
  background-size: 128px 128px, 128px 128px, 32px 32px, 32px 32px;
  mask-image: radial-gradient(ellipse 100% 60% at 50% 20%, black 40%, transparent 90%);
  -webkit-mask-image: radial-gradient(ellipse 100% 60% at 50% 20%, black 40%, transparent 90%);
}

.scanline{
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0px,
    rgba(0,0,0,0) 2px,
    rgba(0,0,0,0.18) 3px,
    rgba(0,0,0,0.18) 4px
  );
}

.crt-vignette{
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse 80% 80% at 50% 50%, transparent 55%, rgba(0,0,0,0.55) 100%);
}

/* ---- pixel border utility ---- */
.pixel-border{
  border: 4px solid var(--white);
  box-shadow:
    0 0 0 4px var(--black),
    0 0 0 8px var(--white);
}

/* ---- topbar ---- */
.topbar{
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--black);
  border-bottom: 4px solid var(--amber);
}
.topbar-inner{
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}
.brand{
  color: var(--white);
  text-decoration: none;
  font-family: var(--pixel);
  font-size: 13px;
  letter-spacing: 0;
}
.brand-dot{ color: var(--amber); }

.hud{
  display: flex;
  gap: 18px;
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--amber);
}
.hud-item{ display: flex; align-items: center; gap: 4px; }

.music-btn{
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--white);
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 8px 10px;
  cursor: pointer;
  transition: transform 0.08s steps(1), border-color 0.1s ease, color 0.1s ease;
}
.music-btn:hover{ border-color: var(--amber); color: var(--amber); }
.music-btn:active{ transform: translate(2px,2px); }
.music-btn.is-on{
  background: var(--green);
  color: var(--black);
  border-color: var(--white);
}
.music-btn:focus-visible{ outline: 2px dashed var(--amber); outline-offset: 3px; }

nav{ display: flex; gap: 22px; }
nav a{
  color: var(--cyan);
  text-decoration: none;
  font-family: var(--pixel);
  font-size: 10px;
  transition: color 0.1s ease;
}
nav a::before{ content: "▸ "; color: var(--red); }
nav a:hover{ color: var(--amber); }
nav a:focus-visible{ outline: 2px dashed var(--amber); outline-offset: 4px; }

/* ---- main layout ---- */
main{
  position: relative;
  z-index: 1;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---- hero / title screen ---- */
.fighter-canvas.screen-shake{
  animation: screen-shake 0.5s steps(2, end);
}
@keyframes screen-shake{
  0%,100%{ transform: translate(0,0); }
  20%{ transform: translate(-6px,4px); }
  40%{ transform: translate(6px,-4px); }
  60%{ transform: translate(-4px,-6px); }
  80%{ transform: translate(4px,6px); }
}
body.konami-active .grid-overlay{
  animation: konami-flash 0.4s steps(1) infinite;
}
@keyframes konami-flash{
  0%,100%{ filter: hue-rotate(0deg); }
  50%{ filter: hue-rotate(90deg); }
}

.hero{
  min-height: 78vh;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
}
.fighter-canvas{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  cursor: crosshair;
  border-bottom: 3px dashed var(--line);
}
.hero-inner{
  padding: 70px 0 60px;
  position: relative;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(to right, rgba(15,10,30,0.88) 0%, rgba(15,10,30,0.88) 55%, rgba(15,10,30,0.4) 80%, transparent 100%);
}
.hero-inner .btn, .hero-inner a{ pointer-events: auto; }

.tap-hint{
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--grey-dim);
  margin: 18px 0 0 0;
  letter-spacing: 0.04em;
}

.eyebrow{
  display: inline-block;
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--red);
  letter-spacing: 0.05em;
  margin: 0 0 28px 0;
  animation: title-blink 1.4s steps(1) infinite;
}
@keyframes title-blink{ 0%,49%{ opacity: 1; } 50%,100%{ opacity: 0.4; } }

.hero-name{
  font-family: var(--pixel);
  font-size: clamp(32px, 7vw, 64px);
  line-height: 1.25;
  margin: 0 0 14px 0;
  color: var(--white);
  text-shadow:
    4px 4px 0 var(--red),
    8px 8px 0 var(--amber-dim);
}
.dot{
  color: var(--cyan);
  animation: blink 1s step-end infinite;
}
@keyframes blink{ 50%{ opacity: 0; } }

.hero-sub{
  font-family: var(--pixel);
  font-size: 13px;
  color: var(--cyan);
  margin: 0 0 22px 0;
  letter-spacing: 0.02em;
}

.hero-tag{
  color: var(--grey);
  font-size: 20px;
  max-width: 560px;
  margin: 0 0 34px 0;
}

.status-line{
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--grey);
  font-size: 16px;
  margin: 30px 0 0 0;
}
.status-dot{
  width: 10px; height: 10px;
  background: var(--green);
  box-shadow: 0 0 0 2px var(--black), 0 0 0 3px var(--green);
  flex-shrink: 0;
  animation: pulse 1s steps(1) infinite;
}
@keyframes pulse{ 0%,49%{ opacity: 1; } 50%,100%{ opacity: 0.3; } }

.accent{ color: var(--amber); }

.hero-links{ display: flex; gap: 16px; flex-wrap: wrap; }

/* ---- pixel buttons ---- */
.btn{
  font-family: var(--pixel);
  font-size: 12px;
  padding: 16px 22px;
  text-decoration: none;
  color: var(--white);
  background: var(--panel);
  border: 3px solid var(--white);
  box-shadow: 4px 4px 0 0 var(--black), 4px 4px 0 3px var(--white);
  transition: transform 0.08s steps(1), box-shadow 0.08s steps(1);
}
.btn--solid{
  background: var(--red);
  border-color: var(--white);
  color: var(--white);
}
.btn--solid:hover, .btn--ghost:hover{
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 0 var(--black), 0 0 0 3px var(--white);
}
.btn:active{ transform: translate(4px,4px); box-shadow: none; }
.btn:focus-visible{ outline: 2px dashed var(--amber); outline-offset: 4px; }

/* ---- sections ---- */
.section{
  padding: 70px 0;
  border-top: 3px dashed var(--line);
}
.section--last{ padding-bottom: 60px; }

.feature-eyebrow{
  font-family: var(--pixel);
  font-size: 13px;
  color: var(--amber);
  margin: 0 0 30px 0;
}

.feature-section{
  padding: 70px 0;
  border-top: 3px dashed var(--line);
}
.feature-grid{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.feature{
  background: var(--panel);
  border: 3px solid var(--line);
  box-shadow: 5px 5px 0 0 var(--black), 5px 5px 0 3px var(--line);
  padding: 24px;
  transition: transform 0.1s steps(1), box-shadow 0.1s steps(1);
}
.feature:hover{
  transform: translate(-3px,-3px);
  box-shadow: 8px 8px 0 0 var(--black), 8px 8px 0 3px var(--amber);
  border-color: var(--amber);
}
.feature--wide{ grid-column: 1 / -1; }
.feature-num{
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--cyan);
  margin: 0 0 14px 0;
}
.feature h3{
  font-family: var(--pixel);
  font-size: 13px;
  font-weight: normal;
  margin: 0 0 14px 0;
  color: var(--white);
  line-height: 1.5;
}
.feature p{
  color: var(--grey);
  font-size: 17px;
  margin: 0 0 16px 0;
}

/* pixel HP-style bars */
.bar-row{ display: flex; align-items: center; gap: 10px; }
.bar-label{
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--grey);
  flex-shrink: 0;
  width: 70px;
}
.bar{
  flex: 1;
  height: 14px;
  background: var(--black);
  border: 2px solid var(--white);
  padding: 2px;
}
.bar-fill{
  height: 100%;
  background: repeating-linear-gradient(
    to right,
    var(--green) 0px, var(--green) 4px,
    #2fa83f 4px, #2fa83f 8px
  );
}

/* ---- achievement badges ---- */
.badges-row{ margin-top: 32px; }
.badges-label{
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--grey);
  margin: 0 0 14px 0;
}
.badges{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.badge{
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--white);
  background: var(--black);
  border: 2px solid var(--amber);
  padding: 10px 12px;
  transition: transform 0.1s steps(1), background 0.1s ease, color 0.1s ease;
}
.badge:hover{
  background: var(--amber);
  color: var(--black);
  transform: translate(-2px,-2px);
}

/* ---- difficulty select ---- */
.difficulty-row{ margin-top: 40px; }
.difficulty-grid{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.diff-item{
  font-size: 16px;
  color: var(--white);
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.diff-tag{
  font-family: var(--pixel);
  font-size: 8px;
  padding: 5px 8px;
  flex-shrink: 0;
}
.diff-easy .diff-tag{ background: var(--green); color: var(--black); }
.diff-normal .diff-tag{ background: var(--amber); color: var(--black); }
.diff-hard .diff-tag{ background: var(--red); color: var(--white); }

/* ---- boss phase marker ---- */
.boss-phase{
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--red);
  flex-shrink: 0;
  animation: title-blink 1.4s steps(1) infinite;
}

/* ---- project cards: character select ---- */
.project-list{
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.project{
  border: 3px solid var(--line);
  background: var(--panel);
  box-shadow: 5px 5px 0 0 var(--black), 5px 5px 0 3px var(--line);
  padding: 26px 28px;
  transition: transform 0.1s steps(1), box-shadow 0.1s steps(1), border-color 0.1s steps(1);
}
.project:hover{
  transform: translate(-3px,-3px);
  border-color: var(--red);
  box-shadow: 8px 8px 0 0 var(--black), 8px 8px 0 3px var(--red);
}
.project-top{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}
.project-top h3{
  margin: 0;
  font-family: var(--pixel);
  font-size: 15px;
  font-weight: normal;
  color: var(--white);
}
.project-status{
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--black);
  background: var(--green);
  padding: 6px 10px;
}
.project-desc{
  color: var(--grey);
  margin: 0 0 18px 0;
  font-size: 17px;
}
.project-tags{
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
}
.project-tags li{
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--black);
  background: var(--cyan);
  padding: 6px 10px;
}

/* ---- boss battle (math) ---- */
.boss-hp-row{
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}
.boss-name{
  font-family: var(--pixel);
  font-size: 13px;
  color: var(--red);
  flex-shrink: 0;
}
.boss-bar{ height: 20px; }
.boss-fill{
  background: repeating-linear-gradient(
    to right,
    var(--red) 0px, var(--red) 4px,
    #b3223c 4px, #b3223c 8px
  );
}

.math-block p{
  color: var(--grey);
  max-width: 640px;
  margin: 0 0 24px 0;
  font-size: 18px;
}
.math-tags{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.math-tags span{
  font-family: var(--pixel);
  font-size: 9px;
  border: 2px solid var(--amber);
  padding: 10px 14px;
  color: var(--amber);
  background: var(--black);
  transition: transform 0.1s steps(1);
}
.math-tags span:hover{
  transform: translate(-2px,-2px);
  background: var(--amber);
  color: var(--black);
}

/* ---- contact / continue screen ---- */
.contact-links{
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.contact-links a{
  color: var(--white);
  text-decoration: none;
  font-family: var(--pixel);
  font-size: 11px;
  border: 2px solid var(--line);
  padding: 14px 18px;
  background: var(--panel);
  transition: color 0.1s ease, border-color 0.1s ease, transform 0.1s steps(1);
}
.contact-links a:hover{
  color: var(--black);
  background: var(--amber);
  border-color: var(--amber);
  transform: translate(-2px,-2px);
}
.contact-links a:focus-visible{ outline: 2px dashed var(--amber); outline-offset: 4px; }

/* ---- footer ---- */
.site-footer{
  position: relative;
  z-index: 1;
  text-align: center;
  color: var(--grey-dim);
  font-family: var(--pixel);
  font-size: 8px;
  padding: 30px 24px 40px;
  border-top: 3px dashed var(--line);
  letter-spacing: 0.02em;
}

/* ---- responsive ---- */
@media (max-width: 640px){
  .topbar-inner{ flex-direction: column; gap: 14px; align-items: flex-start; }
  nav{ gap: 16px; flex-wrap: wrap; }
  .feature-grid{ grid-template-columns: 1fr; }
  .difficulty-grid{ grid-template-columns: 1fr; }
  .hero{ min-height: 60vh; }
  .section, .feature-section{ padding: 50px 0; }
  .hero-name{ text-shadow: 2px 2px 0 var(--red), 4px 4px 0 var(--amber-dim); }
}

/* ---- reduced motion ---- */
@media (prefers-reduced-motion: reduce){
  .dot, .status-dot, .eyebrow{ animation: none; }
  html{ scroll-behavior: auto; }
}
