:root {
  --ink: #0a0610;
  --pink: #ff2a85;
  --cream: #f4e8dc;
}

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

html,
body {
  height: 100%;
}

body {
  background: var(--ink);
  color: var(--cream);
  font-family: Silkscreen, "Press Start 2P", monospace;
  overflow: hidden;
  touch-action: manipulation;
}

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.is-hidden {
  display: none !important;
}

.power {
  position: fixed;
  inset: 0;
  z-index: 50;
  border: 0;
  background:
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.35) 50%),
    radial-gradient(circle at 50% 42%, #2a1838, #0a0610 70%);
  background-size: 100% 4px, auto;
  text-align: center;
}

.power-label {
  display: block;
  margin-top: 38vh;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(0.85rem, 3vw, 1.15rem);
  letter-spacing: 0.28em;
  color: var(--pink);
  text-shadow:
    0 0 8px rgba(255, 42, 133, 0.8),
    0 0 15px rgba(255, 42, 133, 0.4);
}

.power-hint {
  display: block;
  margin-top: 0.9rem;
  font-size: 1.1rem;
}

.loadbar {
  width: min(240px, 60vw);
  height: 10px;
  margin: 1.2rem auto 0;
  border: 2px solid #1a1020;
  background: #120814;
}

.loadbar i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--pink);
}

.power.is-booting .loadbar i {
  animation: fill-bar 0.5s steps(8, end) forwards;
}

@keyframes fill-bar {
  to { width: 100%; }
}

.page {
  min-height: 100%;
  display: grid;
  place-items: center;
}

.app-screen-container {
  display: grid;
  place-items: center;
  width: 100%;
}

.crt-viewport,
.game-viewport {
  --screen-top: 15.97%;
  --screen-left: 38.48%;
  --screen-width: 35.84%;
  --screen-height: 48.44%;

  position: relative;
  width: min(96vw, calc(96vh * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  image-rendering: pixelated;
  background: #000;
}

.layer-video {
  position: absolute;
  z-index: 10;
  top: var(--screen-top);
  left: var(--screen-left);
  width: var(--screen-width);
  height: var(--screen-height);
  object-fit: cover;
}

.layer-ui {
  position: absolute;
  z-index: 20;
  top: var(--screen-top);
  left: var(--screen-left);
  width: var(--screen-width);
  height: var(--screen-height);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 7% 8%;
}

.title {
  margin-bottom: 1rem;
  font-size: clamp(0.42rem, 1.35vw, 0.72rem);
  color: var(--pink);
  text-shadow:
    0 0 8px rgba(255, 42, 133, 0.8),
    0 0 15px rgba(255, 42, 133, 0.4);
}

.menu {
  list-style: none;
  display: grid;
  gap: 0.45rem;
}

.menu button {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  border: 0;
  background: transparent;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(0.32rem, 0.95vw, 0.52rem);
  line-height: 1.5;
  color: var(--cream);
  text-align: left;
}

.menu button.is-active,
.menu button:hover {
  color: var(--pink);
  text-shadow:
    0 0 8px rgba(255, 42, 133, 0.8),
    0 0 15px rgba(255, 42, 133, 0.4);
}

.caret {
  display: inline-block;
  width: 0.9em;
  color: var(--pink);
}

.desktop {
  display: block;
  padding: 0.45rem;
  background: rgba(12, 6, 20, 0.55);
}

.icons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem 0.25rem;
}

.icon {
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  font-size: clamp(0.55rem, 1.1vw, 0.8rem);
  font-family: Silkscreen, monospace;
  color: var(--cream);
}

.icon-face {
  width: 18px;
  height: 14px;
  border: 2px solid #1a1020;
  background: var(--pink);
}

.icon[data-app="intel"] .icon-face { background: #7ec8d4; }
.icon[data-app="market"] .icon-face { background: #c48a5a; }
.icon[data-app="coin"] .icon-face { background: #e0b24a; }
.icon[data-app="web"] .icon-face { background: #5a7ad0; }
.icon[data-app="create"] .icon-face { background: #6aaa5a; }
.icon[data-app="her"] .icon-face { background: #ff9ec5; }
.icon[data-app="vhs"] .icon-face { background: #5a3a48; }

.win-layer {
  position: absolute;
  inset: 0.35rem;
  pointer-events: none;
}

.window {
  position: absolute;
  width: min(86%, 210px);
  pointer-events: auto;
  border: 2px solid var(--pink);
  background: #2a1030;
}

.window header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.2rem 0.3rem;
  background: var(--pink);
  font-family: "Press Start 2P", monospace;
  font-size: 0.32rem;
  cursor: grab;
}

.window .body {
  padding: 0.4rem;
  font-size: 0.85rem;
  font-family: Silkscreen, monospace;
}

.window .x {
  width: 14px;
  height: 14px;
  border: 0;
  background: var(--cream);
  color: #1a1020;
  font-size: 0.65rem;
  line-height: 1;
}

.win-btn,
.body a,
.body button[type="submit"] {
  display: inline-block;
  margin-top: 0.3rem;
  padding: 0.2rem 0.35rem;
  border: 0;
  background: var(--pink);
  color: #1a1020;
  font-family: "Press Start 2P", monospace;
  font-size: 0.32rem;
  text-decoration: none;
}

.body input {
  width: 100%;
  margin: 0.3rem 0;
  padding: 0.25rem;
  border: 1px solid var(--pink);
  background: #120814;
  color: var(--cream);
  font: inherit;
}

.error { color: #ff6b8a; min-height: 1em; }
.dim { opacity: 0.65; }
.window.is-shake { animation: shake 0.25s steps(4, end); }
@keyframes shake {
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}
.blink { animation: caret 0.8s steps(1, end) infinite; }
@keyframes caret { 50% { opacity: 0; } }

@media (max-width: 768px) {
  html,
  body,
  .page {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
  }

  .app-screen-container {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    padding:
      env(safe-area-inset-top, 0px)
      env(safe-area-inset-right, 0px)
      env(safe-area-inset-bottom, 0px)
      env(safe-area-inset-left, 0px);
    overflow: hidden;
    background: var(--ink);
  }

  .crt-viewport,
  .game-viewport {
    width: 100vw;
    max-width: 100vw;
    height: auto;
    aspect-ratio: 16 / 9;
    flex-shrink: 0;
    clip-path: inset(6.5% 23% 31% 32.5%);
    transform: translate(-6.4vw, 5.51vw) scale(2.28);
    transform-origin: 56.4% 40.2%;
  }

  .layer-ui {
    padding: 5% 6%;
  }

  .title {
    margin-bottom: 0.55rem;
    font-size: clamp(0.36rem, 1.8vw, 0.5rem);
  }

  .menu {
    gap: 0.22rem;
  }

  .menu button {
    padding: 0.12em 0.08em;
    font-size: clamp(0.36rem, 1.9vw, 0.48rem);
  }

  .icon {
    padding: 0.15rem 0;
  }
}

.layer-fx {
  position: absolute;
  z-index: 30;
  top: var(--screen-top);
  left: var(--screen-left);
  width: var(--screen-width);
  height: var(--screen-height);
  pointer-events: none;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.35) 50%);
  background-size: 100% 4px;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.7);
  animation: flicker 6s steps(2, end) infinite;
}

@keyframes flicker {
  50% { opacity: 0.92; }
}

.layer-frame {
  position: absolute;
  z-index: 40;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  image-rendering: pixelated;
  user-select: none;
}
