:root {
  --bg: #07010c;
  --pink: #ffb6e8;
  --pink-deep: #d574a4;
  --lavender: #d6dfff;
  --ink: #1b1233;
  --panel: #cfd6f5;
  --border: #1b1e5d;
  --art-ratio: calc(1920 / 1241);
  --dock-h: 0px;
  --rail-h: 0px;
  --app-h: 100dvh;
  --art-w: min(100vw, calc(var(--app-h) * var(--art-ratio)));
  --art-h: min(var(--app-h), calc(100vw / var(--art-ratio)));
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --cursor-default: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18'%3E%3Cpath fill='%23fff' stroke='%23120116' stroke-width='1' d='M2 1v15l4.2-3.6 2.6 6.2 2.2-.9-2.6-6.2H15z'/%3E%3C/svg%3E") 2 1, auto;
  --cursor-click: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18'%3E%3Cpath fill='%23ffb6e8' stroke='%23120116' stroke-width='1' d='M2 1v15l4.2-3.6 2.6 6.2 2.2-.9-2.6-6.2H15z'/%3E%3C/svg%3E") 2 1, pointer;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: var(--app-h, 100dvh);
  background: var(--bg);
  color: #fff;
  font-family: "Press Start 2P", monospace;
  overflow: hidden;
  overscroll-behavior: none;
  cursor: var(--cursor-default);
}

body {
  display: flex;
  flex-direction: column;
  padding: var(--safe-t) var(--safe-r) 0 var(--safe-l);
}

.crt {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    rgba(0, 0, 0, 0.07) 2px,
    rgba(0, 0, 0, 0.07) 3px
  );
  mix-blend-mode: multiply;
}

.crt::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.28) 100%);
}

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: grid;
  place-items: center;
  background: var(--bg);
  overflow: hidden;
}

.screen {
  position: relative;
  width: var(--art-w);
  height: var(--art-h);
  aspect-ratio: 1920 / 1241;
  flex: 0 0 auto;
  display: none;
  overflow: hidden;
}

.screen.active {
  display: block;
  animation: screen-in 0.38s ease-out;
}

.screen img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  object-position: center;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

@keyframes screen-in {
  from {
    opacity: 0;
    filter: contrast(1.4) saturate(0.4);
    transform: scale(1.015);
  }
  to {
    opacity: 1;
    filter: none;
    transform: none;
  }
}

.hotspot {
  position: absolute;
  z-index: 5;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: var(--cursor-click);
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.hotspot:hover,
.hotspot:focus-visible {
  outline: none;
}

.hotspot:active {
  transform: scale(0.97);
}

#selector {
  position: absolute;
  z-index: 8;
  margin: 0;
  color: var(--pink);
  font-size: clamp(10px, 1.35vw, 16px);
  line-height: 1;
  text-shadow: 2px 2px 0 #120616;
  pointer-events: none;
  transform: translate(-130%, -50%);
  animation: selector-bob 0.45s steps(2, end) infinite;
}

#selector[hidden] {
  display: none;
}

@keyframes selector-bob {
  0% {
    translate: 0 0;
  }
  100% {
    translate: 4px 0;
  }
}

/* --- Start --- */
#s-start .hs-start {
  left: 11%;
  top: 51%;
  width: 17%;
  height: 13%;
}

.social-cover {
  position: absolute;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10%;
  pointer-events: none;
}

.social-cover-start {
  left: 12%;
  top: 81.2%;
  width: 16%;
  height: 10.5%;
  justify-content: flex-start;
  gap: 10%;
  background: none;
}

.social-cover-contact {
  left: 77.5%;
  top: 25%;
  width: 9%;
  height: 34%;
  flex-direction: column;
  gap: 8%;
  background: none;
  padding: 6% 0;
}

.social-btn {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 42%;
  aspect-ratio: 1;
  max-height: 100%;
  background: transparent;
  border: none;
  text-decoration: none;
  cursor: var(--cursor-click);
  touch-action: manipulation;
}

.social-cover-contact .social-btn {
  width: 72%;
  max-height: none;
}

.social-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
}

.social-btn:hover,
.social-btn:focus-visible {
  outline: none;
  transform: scale(1.08);
  filter: brightness(1.12);
}

/* --- Loading --- */
.loading-dots {
  position: absolute;
  left: 50%;
  top: 56%;
  transform: translateX(-50%);
  display: flex;
  gap: clamp(6px, 0.7vw, 12px);
  z-index: 6;
}

.loading-dots span {
  width: clamp(8px, 0.7vw, 14px);
  height: clamp(8px, 0.7vw, 14px);
  background: #fff;
  animation: blink 1s infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.15s;
}
.loading-dots span:nth-child(3) {
  animation-delay: 0.3s;
}
.loading-dots span:nth-child(4) {
  animation-delay: 0.45s;
}
.loading-dots span:nth-child(5) {
  animation-delay: 0.6s;
}
.loading-dots span:nth-child(6) {
  animation-delay: 0.75s;
}

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

/* --- Centered level intros --- */
.hs-start-center {
  left: 37%;
  top: 54%;
  width: 26%;
  height: 12%;
}

.hs-back {
  left: 1.5%;
  top: 2.5%;
  width: 16%;
  height: 8%;
}

/* --- About --- */
#s-about .hs-astro {
  left: 68%;
  top: 58%;
  width: 28%;
  height: 36%;
}

/* --- Side arrows --- */
.hs-left {
  left: 0.5%;
  top: 36%;
  width: 8%;
  height: 26%;
}

.hs-right {
  left: 91.5%;
  top: 36%;
  width: 8%;
  height: 26%;
}

/* --- UFO / next --- */
.hs-ufo-center {
  left: 38%;
  top: 38%;
  width: 24%;
  height: 32%;
}

.hs-ufo-left {
  left: 3%;
  top: 66%;
  width: 14%;
  height: 22%;
}

#s-projects .hs-advance {
  left: 22%;
  top: 16%;
  width: 56%;
  height: 58%;
}

.hs-project-link {
  left: 21%;
  top: 26%;
  width: 24%;
  height: 42%;
}

/* --- Congrats --- */
#s-congrats .hs-contact {
  left: 38%;
  top: 60%;
  width: 24%;
  height: 11%;
}
#s-congrats .hs-l1 {
  left: 82%;
  top: 70%;
  width: 16%;
  height: 6%;
}
#s-congrats .hs-l2 {
  left: 82%;
  top: 76.5%;
  width: 16%;
  height: 6%;
}
#s-congrats .hs-l3 {
  left: 82%;
  top: 83%;
  width: 16%;
  height: 6%;
}
#s-congrats .hs-l4 {
  left: 82%;
  top: 89.5%;
  width: 16%;
  height: 6%;
}

/* --- Contact form overlay --- */
.contact-form {
  position: absolute;
  inset: 0;
  z-index: 6;
  margin: 0;
}

.contact-form input,
.contact-form textarea {
  position: absolute;
  border: none;
  background: #fff;
  color: var(--ink);
  font-family: "Press Start 2P", monospace;
  font-size: clamp(7px, 0.8vw, 10px);
  line-height: 1.6;
  padding: 0.55em 0.8em;
  resize: none;
}

.contact-form .f-name {
  left: 34.9%;
  top: 27.4%;
  width: 40.4%;
  height: 4.2%;
}

.contact-form .f-email {
  left: 34.9%;
  top: 36.5%;
  width: 40.4%;
  height: 4.2%;
}

.contact-form .f-msg {
  left: 34.9%;
  top: 45.6%;
  width: 40.4%;
  height: 19.8%;
}

.contact-form .f-send {
  left: 61%;
  top: 67.6%;
  position: absolute;
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: 2px solid var(--pink);
  outline-offset: 2px;
}

.pixel-btn {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(8px, 0.9vw, 12px);
  color: var(--pink);
  background: #2a1840;
  border: 3px solid #d1b3ff;
  padding: 0.7em 1.1em;
  cursor: var(--cursor-click);
  image-rendering: pixelated;
  touch-action: manipulation;
}

.pixel-btn:hover,
.pixel-btn:focus-visible {
  background: #3d2460;
  color: #fff;
}

.hint {
  position: fixed;
  left: 50%;
  bottom: calc(12px + var(--dock-h) + var(--rail-h) + var(--safe-b));
  transform: translateX(-50%);
  z-index: 30;
  margin: 0;
  font-size: clamp(6px, 1.1vw, 8px);
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.72);
  text-shadow: 2px 2px 0 #000;
  pointer-events: none;
  white-space: nowrap;
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: hint-fade 5.5s ease forwards;
}

@keyframes hint-fade {
  0%,
  65% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.rail {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  padding: 8px 12px;
  background: #110818;
  border-top: 3px solid #3d2460;
  z-index: 26;
}

.rail:not([hidden]) {
  display: flex;
}

.rail a,
.rail button {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: var(--pink);
  background: #2a1840;
  border: 2px solid #d1b3ff;
  padding: 10px 12px;
  text-decoration: none;
  cursor: var(--cursor-click);
  min-height: 40px;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.rail a img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  image-rendering: pixelated;
}

#dock {
  display: none;
  gap: 12px;
  justify-content: space-between;
  padding: 10px 14px calc(10px + var(--safe-b));
  background: #110818;
  border-top: 3px solid #3d2460;
  z-index: 25;
}

body.show-dock #dock {
  display: flex;
}

#dock button {
  flex: 1;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(8px, 2.4vw, 10px);
  color: var(--pink);
  background: #2a1840;
  border: 3px solid #d1b3ff;
  padding: 12px 8px;
  min-height: 48px;
  cursor: var(--cursor-click);
  touch-action: manipulation;
}

#dock button[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(5, 0, 10, 0.72);
}

.modal.hidden {
  display: none;
}

.modal-box {
  width: min(92vw, 420px);
  padding: clamp(18px, 4vw, 28px) clamp(14px, 4vw, 22px);
  background: #1b1233;
  border: 4px solid #d1b3ff;
  text-align: center;
}

.modal-box p {
  margin: 0 0 12px;
  font-size: clamp(10px, 3vw, 12px);
  color: var(--pink);
  line-height: 1.7;
}

.modal-sub {
  font-family: VT323, monospace !important;
  font-size: clamp(18px, 5vw, 22px) !important;
  color: #fff !important;
}

/* ---------- Compact chrome (same art box on every screen) ---------- */
body.compact .hint {
  white-space: normal;
  text-align: center;
  width: min(92vw, 420px);
  font-size: 7px;
  line-height: 1.6;
}

body.compact-form .contact-form {
  inset: auto;
  left: 50%;
  top: max(12px, var(--safe-t));
  transform: translateX(-50%);
  width: min(92vw, 440px);
  max-height: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 14px 14px;
  background: rgba(207, 214, 245, 0.94);
  border: 4px solid var(--border);
  overflow: auto;
}

body.compact-form .contact-form input,
body.compact-form .contact-form textarea {
  position: static;
  width: 100%;
  height: auto;
  min-height: 44px;
  font-family: VT323, monospace;
  font-size: 16px;
  padding: 10px 12px;
}

body.compact-form .contact-form textarea {
  min-height: 110px;
  flex: 1;
}

body.compact-form .contact-form .f-send {
  position: static;
  align-self: stretch;
  min-height: 48px;
  font-size: 12px;
}

/* Tablet in-between: keep art contained, enlarge taps */
@media (max-width: 1100px) {
  .hs-left,
  .hs-right {
    width: 10%;
  }

  .hs-start-center {
    width: 32%;
    left: 34%;
    height: 14%;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  body.show-dock #dock button {
    min-height: 40px;
    padding: 8px;
    font-size: 8px;
  }

  .hint {
    display: none;
  }
}

@media (hover: none) {
  #selector {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen.active,
  #selector,
  .hint,
  .loading-dots span {
    animation: none;
  }
}
