@import url("https://fonts.googleapis.com/css2?family=Anton&family=DM+Mono:wght@500&family=Inter:wght@700;900&display=swap");
:root {
  --lime: #caff45;
  --pink: #f95cff;
  --ink: #09060e;
  --cream: #faf3e6;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 50% 0, #3b174b, #0c0712 55%);
  color: var(--cream);
  font-family: Inter, sans-serif;
}
button,
a {
  cursor: pointer;
}
header {
  height: 58px;
  padding: 0 max(16px, 4vw);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #ffffff18;
  background: #09060ecc;
}
header > a,
header button {
  color: #96889e;
  font: 500 8px DM Mono;
  text-decoration: none;
  letter-spacing: 1px;
}
header b {
  font-size: 20px;
  font-style: italic;
}
header b span {
  color: var(--lime);
}
header > div {
  display: flex;
  gap: 6px;
}
header button {
  padding: 8px;
  border: 1px solid #594365;
  border-radius: 4px;
  background: #160e1d;
}
main {
  width: min(1120px, 96vw);
  margin: auto;
}
.title {
  text-align: center;
  padding: 22px 0 15px;
}
.title small {
  color: var(--lime);
  font: 500 8px DM Mono;
  letter-spacing: 3px;
}
.title h1 {
  margin: 1px 0;
  font: 400 clamp(48px, 7vw, 76px)/1 Anton;
  text-shadow: 5px 5px #000;
}
.title h1 span {
  color: var(--pink);
}
.title p {
  margin: 0;
  color: #a89cac;
  font-size: 10px;
}
.cabinet {
  overflow: hidden;
  border: 1px solid #60496b;
  border-radius: 12px;
  background: #110b17;
  box-shadow: 0 25px 80px #000a;
}
.hud {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-bottom: 1px solid #4d3b56;
  color: #8f8296;
  font: 500 8px DM Mono;
  letter-spacing: 1px;
}
.hud span {
  display: flex;
  align-items: center;
  gap: 7px;
}
.hud b {
  color: var(--lime);
  font-size: 16px;
}
.hud #heartHud {
  color: #ff617d;
}
.screen {
  position: relative;
  height: min(55vw, 560px);
  min-height: 400px;
  overflow: hidden;
  background: #171125;
}
.screen canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.panel,
.tutorial {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: #0c0712ee;
  backdrop-filter: blur(5px);
  transition: 0.25s;
}
.panel.hidden,
.tutorial.closed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.panel img {
  width: 130px;
  height: 130px;
  object-fit: contain;
}
.panel > small,
.tutorial > small {
  color: var(--lime);
  font: 500 8px DM Mono;
  letter-spacing: 3px;
}
.panel h2,
.tutorial h2 {
  margin: 3px 0;
  font: 400 33px Anton;
}
.panel > p,
.tutorial article p {
  max-width: 500px;
  margin: 2px 10px 16px;
  text-align: center;
  color: #aaa0af;
  font-size: 11px;
  line-height: 1.5;
}
.play,
.tutorial-done {
  min-width: 215px;
  padding: 12px 20px;
  border: 0;
  border-radius: 5px;
  background: var(--lime);
  color: #09060e;
  font-weight: 900;
  box-shadow: 0 5px #718f25;
}
.toast {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 18%;
  transform: translate(-50%, -10px);
  padding: 8px 13px;
  border: 1px solid var(--lime);
  border-radius: 5px;
  background: #0a0710dd;
  color: var(--lime);
  font: 500 9px DM Mono;
  letter-spacing: 1px;
  opacity: 0;
  transition: 0.2s;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
#scoreForm {
  width: min(350px, 90%);
  margin: 7px 0 13px;
}
#scoreForm input {
  width: 62%;
  padding: 11px;
  border: 1px solid #654d70;
  border-radius: 4px 0 0 4px;
  background: #0d0812;
  color: white;
}
#scoreForm button {
  width: 38%;
  padding: 12px 5px;
  border: 0;
  border-radius: 0 4px 4px 0;
  background: var(--pink);
  color: white;
  font-weight: 900;
}
#formError {
  display: block;
  min-height: 12px;
  color: #ff8594;
  font: 500 8px DM Mono;
}
.tutorial > button:first-child {
  position: absolute;
  right: 12px;
  top: 12px;
  padding: 8px;
  border: 1px solid #60496b;
  border-radius: 4px;
  background: #130b19;
  color: #998ca0;
  font: 500 8px DM Mono;
}
.slides {
  position: relative;
  width: min(620px, 94%);
  height: 285px;
}
.slides article {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateX(20px);
  pointer-events: none;
  transition: 0.25s;
}
.slides article.active {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.slides img {
  width: 135px;
  height: 145px;
  object-fit: contain;
}
.demo {
  display: flex;
  height: 145px;
}
.demo img {
  width: 120px;
}
.tutorial-nav {
  display: flex;
  align-items: center;
  gap: 15px;
}
.tutorial-nav > button {
  width: 38px;
  height: 36px;
  border: 1px solid #55415f;
  border-radius: 4px;
  background: #170e1e;
  color: white;
  font-size: 20px;
}
.tutorial-nav > div {
  display: flex;
  gap: 7px;
}
.tutorial-nav > div button {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #65576b;
}
.tutorial-nav > div button.active {
  background: var(--lime);
  box-shadow: 0 0 8px var(--lime);
}
.tutorial-done {
  margin-top: 10px;
}
.mobile-controls {
  display: none;
}
#exitGameMode,
.rotate-device {
  display: none;
}
.records {
  display: grid;
  grid-template-columns: 190px 1fr;
  margin: 14px 0;
  padding: 11px 16px;
  border: 1px solid #44344d;
  border-radius: 8px;
  background: #0c0811;
}
.records > div {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.records > div b {
  color: var(--lime);
  font: 500 10px DM Mono;
}
.records > div small {
  color: #706576;
  font: 500 8px DM Mono;
}
.records ol {
  counter-reset: r;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
  margin: 0;
  padding: 0;
}
.records li {
  counter-increment: r;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  padding: 5px;
  border-bottom: 1px solid #29202e;
  color: #9e92a4;
  font: 500 9px DM Mono;
}
.records li:before {
  content: counter(r, decimal-leading-zero);
  color: #62566a;
}
.records li b {
  color: white;
}
.records li span {
  color: var(--pink);
}
nav {
  display: flex;
  justify-content: center;
  gap: 7px;
  padding-bottom: 25px;
  flex-wrap: wrap;
}
nav a {
  padding: 8px;
  color: #817587;
  text-decoration: none;
  font: 500 8px DM Mono;
}
nav a:hover {
  color: var(--lime);
}
@media (max-width: 950px) {
  header {
    height: 48px;
    padding: 0 9px;
  }
  header b {
    font-size: 14px;
  }
  header > a {
    font-size: 6px;
  }
  header button {
    font-size: 6px;
    padding: 7px 5px;
  }
  .title {
    padding: 9px 0 7px;
  }
  .title h1 {
    font-size: 38px;
  }
  .title p {
    display: none;
  }
  main {
    width: 100%;
  }
  .cabinet {
    border-radius: 0;
    border-inline: 0;
  }
  .hud {
    height: 42px;
    padding: 0 3px;
  }
  .hud span {
    display: grid;
    gap: 1px;
    text-align: center;
    font-size: 6px;
  }
  .hud b {
    font-size: 12px;
  }
  .screen {
    height: calc(100dvh - 145px);
    min-height: 430px;
  }
  .mobile-controls {
    position: absolute;
    z-index: 6;
    left: 8px;
    right: 8px;
    bottom: 8px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 148px;
    padding: 0 8px;
    border: 0;
    background: none;
    box-shadow: none;
    pointer-events: none;
  }
  .mobile-controls button,
  .mobile-controls span {
    box-sizing: border-box;
  }
  .mobile-controls button {
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  .nes-dpad {
    position: relative;
    width: 142px;
    height: 142px;
    border: 1px solid #ffffff52;
    border-radius: 50%;
    background: #07101b18;
    box-shadow: inset 0 0 18px #0003, 0 2px 8px #0004;
  }
  .nes-dpad button,
  .nes-dpad span {
    position: absolute;
    width: 46px;
    height: 46px;
    border: 1px solid #ffffff40;
    border-radius: 50%;
    background: #1017222e;
    color: #ffffffa6;
    font-size: 12px;
    line-height: 44px;
    text-align: center;
    box-shadow: inset 0 0 10px #0004;
  }
  .nes-dpad .dpad-up { left: 48px; top: 1px; opacity: .42; }
  .nes-dpad #leftBtn { left: 1px; top: 48px; }
  .nes-dpad .dpad-center {
    left: 48px;
    top: 48px;
    border-color: #ffffff2b;
    background: #ffffff12;
    box-shadow: inset 0 0 10px #0003;
  }
  .nes-dpad .dpad-center::after {
    content: "";
    position: absolute;
    inset: 14px;
    border-radius: 50%;
    background: #ffffff20;
  }
  .nes-dpad #rightBtn { right: 1px; top: 48px; }
  .nes-dpad #downLeftBtn { left: 2px; bottom: 8px; }
  .nes-dpad #duckBtn { left: 48px; bottom: 1px; }
  .nes-dpad #downRightBtn { right: 2px; bottom: 8px; }
  .nes-dpad {
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
  }
  .nes-dpad .stick-ring {
    position: absolute;
    inset: 18px;
    width: auto;
    height: auto;
    border: 1px solid #ffffff35;
    border-radius: 50%;
    background: radial-gradient(circle, #ffffff08 0 43%, transparent 44%);
    box-shadow: inset 0 0 16px #0005;
  }
  .stick-ring::before,
  .stick-ring::after {
    content: "";
    position: absolute;
    background: #ffffff24;
  }
  .stick-ring::before { inset: 50% 9px auto; height: 1px; }
  .stick-ring::after { inset: 9px auto 9px 50%; width: 1px; }
  .nes-dpad .stick-knob {
    position: absolute;
    z-index: 2;
    left: 42px;
    top: 42px;
    width: 58px;
    height: 58px;
    border: 1px solid #ffffff7a;
    border-radius: 50%;
    background: radial-gradient(circle at 38% 32%, #ffffff42, #56637270 42%, #11192780 72%);
    box-shadow: inset 0 0 0 8px #11192738, 0 3px 10px #0008;
    transition: transform 70ms ease-out;
    will-change: transform;
  }
  .nes-dpad.active { border-color: #caff458c; }
  .nes-dpad.active .stick-knob {
    border-color: #caff45c7;
    transition: none;
  }
  .nes-dpad button:active,
  .nes-actions button:active {
    transform: scale(.92);
    border-color: #caff45c7;
    background: #caff4540;
    color: white;
    filter: none;
  }
  .nes-menu {
    display: none;
    align-items: center;
    gap: 6px;
    margin: 0 7px 8px;
    padding: 5px 6px 3px;
    border-radius: 5px;
    background: #aaa8;
  }
  .nes-menu span {
    width: 22px;
    height: 7px;
    border-radius: 8px;
    background: #292929;
    box-shadow: inset 0 2px #111;
  }
  .nes-menu small {
    position: absolute;
    margin-top: 23px;
    color: #7b1724;
    font: 700 5px Arial, sans-serif;
    letter-spacing: .4px;
  }
  .nes-actions {
    position: relative;
    display: block;
    width: 142px;
    height: 142px;
    padding: 8px;
    border: 1px solid #ffffff52;
    border-radius: 50%;
    background: #07101b18;
    box-shadow: inset 0 0 18px #0003, 0 2px 8px #0004;
  }
  .nes-actions button {
    position: absolute;
    width: 58px;
    height: 58px;
    border: 1px solid #ffffff70;
    border-radius: 50%;
    background: #b91f3638;
    color: #ffffffd1;
    box-shadow: inset 0 0 13px #9b102751;
  }
  .nes-actions #runBtn { left: 13px; bottom: 14px; }
  .nes-actions #jumpBtn { right: 13px; top: 14px; }
  .nes-actions b {
    display: block;
    font: 900 17px Arial, sans-serif;
    text-shadow: 0 1px 3px #000;
  }
  .cabinet {
    position: relative;
  }
  .panel {
    padding: 12px;
  }
  .panel img {
    width: 95px;
    height: 95px;
  }
  .panel h2 {
    font-size: 28px;
  }
  .panel > p {
    font-size: 10px;
  }
  .tutorial {
    justify-content: center;
    padding: 8px 8px 75px;
  }
  .slides {
    height: min(48dvh, 270px);
  }
  .slides img {
    width: 105px;
    height: 115px;
  }
  .demo {
    height: 115px;
  }
  .demo img {
    width: 90px;
  }
  .tutorial article p {
    font-size: 10px;
  }
  .records {
    grid-template-columns: 1fr;
    margin: 8px 0;
    border-inline: 0;
    border-radius: 0;
  }
  .records > div {
    flex-direction: row;
    justify-content: space-between;
    margin-bottom: 6px;
  }
  .records ol {
    grid-template-columns: 1fr 1fr;
    gap: 0 10px;
  }
  nav {
    padding: 0 8px 20px;
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  nav::-webkit-scrollbar { display: none; }
  nav a {
    white-space: nowrap;
  }
}

@media (max-width: 950px) and (orientation: portrait) {
  body.game-mode .rotate-device {
    position: fixed;
    z-index: 10000;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 9px;
    background: #09060ef5;
    color: var(--lime);
    text-align: center;
  }
  body.game-mode .rotate-device span { font-size: 58px; }
  body.game-mode .rotate-device b {
    font: 500 15px DM Mono;
    letter-spacing: 2px;
  }
  body.game-mode .rotate-device small {
    color: #a99eae;
    font-size: 10px;
  }
}

@media (max-width: 950px) and (orientation: landscape) {
  body.game-mode {
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    background: #000;
  }
  body.game-mode > header,
  body.game-mode main > .title,
  body.game-mode .records,
  body.game-mode main > nav,
  body.game-mode .booter-radio,
  body.game-mode .booter-install { display: none !important; }
  body.game-mode main {
    width: 100vw;
    height: 100dvh;
    margin: 0;
  }
  body.game-mode .cabinet {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  body.game-mode .hud {
    position: absolute;
    z-index: 7;
    inset: 0 0 auto;
    height: 34px;
    padding: 0 52px 0 8px;
    background: #09060edb;
  }
  body.game-mode .hud span {
    display: flex;
    gap: 4px;
    font-size: 6px;
  }
  body.game-mode .hud b { font-size: 11px; }
  body.game-mode .screen {
    position: absolute;
    inset: 34px 0 0;
    width: 100%;
    height: auto;
    min-height: 0;
  }
  body.game-mode .mobile-controls {
    position: absolute;
    z-index: 9;
    inset: auto max(8px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    height: 148px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 8px;
    pointer-events: none;
    border: 0;
    background: none;
    box-shadow: none;
  }
  body.game-mode .mobile-controls button {
    pointer-events: auto;
    opacity: .88;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  body.game-mode .mobile-controls button:active {
    opacity: 1;
  }
  body.game-mode #exitGameMode {
    position: absolute;
    z-index: 12;
    top: max(4px, env(safe-area-inset-top));
    right: max(7px, env(safe-area-inset-right));
    display: block;
    width: 27px;
    height: 27px;
    padding: 0;
    border: 1px solid #ffffff40;
    border-radius: 50%;
    background: #100a18b8;
    color: #bbb0c1;
    font-size: 18px;
  }
  body.game-mode .panel,
  body.game-mode .tutorial { padding: 8px 155px 112px; }
  body.game-mode .panel img,
  body.game-mode .slides img {
    width: 70px;
    height: 70px;
  }
  body.game-mode .panel h2,
  body.game-mode .tutorial h2 { font-size: 24px; }
  body.game-mode .slides { height: min(47dvh, 185px); }
}
@media (max-width: 420px) {
  .records ol {
    grid-template-columns: 1fr;
  }
  .records li:nth-child(n + 6) {
    display: none;
  }
}
@media (max-width: 390px) and (max-height: 720px) {
  .title {
    display: none;
  }
  .screen {
    height: calc(100dvh - 91px);
    min-height: 0;
  }
  .records {
    display: none;
  }
  .slides {
    height: 230px;
  }
  .panel img {
    width: 72px;
    height: 72px;
  }
}

@media (max-width: 950px) {
  .mobile-controls,
  body.game-mode .mobile-controls {
    position: absolute;
    z-index: 9;
    inset: 42px 0 0;
    display: block;
    width: auto;
    height: auto;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    pointer-events: none;
  }
  body.game-mode .mobile-controls { inset: 34px 0 0; }
  .touch-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    border: 0;
    background: transparent;
    pointer-events: none;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  body.playing .touch-zone { pointer-events: auto; }
  .move-zone { left: 0; }
  .jump-zone { right: 0; }
  .thumb-ring {
    --thumb-x: 0px;
    --thumb-y: 0px;
    position: absolute;
    width: 92px;
    height: 92px;
    border: 1px solid #ffffff42;
    border-radius: 50%;
    background: #07101b0d;
    box-shadow: inset 0 0 18px #0003;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%);
    transition: opacity 100ms ease;
  }
  .thumb-ring::after {
    content: "";
    position: absolute;
    left: 25px;
    top: 25px;
    width: 40px;
    height: 40px;
    border: 1px solid #caff4580;
    border-radius: 50%;
    background: #caff451c;
    transform: translate(var(--thumb-x), var(--thumb-y));
  }
  .jump-zone .thumb-ring::after {
    border-color: #ff607a91;
    background: #b91f3626;
  }
  .thumb-ring.active { opacity: .72; }
  body.game-mode .tutorial { padding: 10px 90px; }
  body.game-mode .panel {
    justify-content: center;
    padding: 10px max(54px, env(safe-area-inset-left)) 10px max(54px, env(safe-area-inset-right));
  }
  body.game-mode .panel #scoreForm {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(105px, auto);
    width: min(380px, 72vw);
    margin: 7px auto 12px;
  }
  body.game-mode .panel #scoreForm input,
  body.game-mode .panel #scoreForm button { width: 100%; }
  body.game-mode .panel #formError { grid-column: 1 / -1; }
  body.game-mode .panel .play { min-width: min(240px, 62vw); }
}
