* {
  box-sizing: border-box;
}

:root {
  --terminal-white: #f2f7ff;
  --terminal-dim: rgba(228, 237, 255, 0.78);
  --terminal-sheen-a: rgba(181, 233, 255, 0.42);
  --terminal-sheen-b: rgba(255, 221, 244, 0.22);
  --vn-width: 1100px;
  --vn-height: 619px;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #000;
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body {
  min-height: 100vh;
  font-family: "IBM Plex Mono", monospace;
}

button {
  font: inherit;
}

.copyright {
  position: fixed;
  right: 16px;
  bottom: 10px;
  z-index: 9;
  color: var(--terminal-dim);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.app {
  position: relative;
  min-height: 100vh;
  background: #000;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.begin-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: #000;
}

.begin-overlay.hidden {
  display: none;
}

.begin-button {
  border: 1px solid rgba(242, 247, 255, 0.34);
  background: #060709;
  color: var(--terminal-white);
  padding: 14px 28px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  box-shadow:
    0 0 0 1px rgba(181, 233, 255, 0.08) inset,
    0 0 28px rgba(181, 233, 255, 0.08);
}

.screen-shell {
  width: min(100vw, calc(var(--vn-width) + 60px));
  padding: 24px;
}

.screen-bezel {
  position: relative;
  border-radius: 30px;
  padding: 18px;
  background:
    linear-gradient(145deg, rgba(34, 37, 49, 0.98), rgba(12, 14, 21, 0.98) 58%, rgba(30, 24, 38, 0.98)),
    radial-gradient(circle at top left, rgba(181, 233, 255, 0.16), transparent 34%),
    radial-gradient(circle at bottom right, rgba(255, 221, 244, 0.12), transparent 30%);
  border: 1px solid rgba(242, 247, 255, 0.14);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 18px 60px rgba(0, 0, 0, 0.64),
    0 0 40px rgba(181, 233, 255, 0.08);
}

.screen-bezel::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 22px;
  border: 1px solid rgba(181, 233, 255, 0.1);
  pointer-events: none;
}

.screen-inner {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  width: min(100%, var(--vn-width));
  aspect-ratio: 1100 / 619;
  background:
    linear-gradient(180deg, rgba(8, 10, 16, 0.98), rgba(1, 2, 5, 0.99)),
    #000;
  border: 1px solid rgba(242, 247, 255, 0.08);
  box-shadow:
    0 0 0 1px rgba(181, 233, 255, 0.05) inset,
    0 0 26px rgba(181, 233, 255, 0.05) inset;
}

.screen-inner::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 10%, transparent 88%, rgba(255, 255, 255, 0.035)),
    radial-gradient(circle at 50% 50%, transparent 58%, rgba(0, 0, 0, 0.22) 100%),
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.028) 0 1px, transparent 1px 4px);
  mix-blend-mode: screen;
  opacity: 0.5;
  pointer-events: none;
}

.scene {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 0;
  padding: 0;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

.image-stage {
  width: 100%;
  height: calc(100% - 154px);
  flex: 0 0 auto;
  position: relative;
  display: block;
  overflow: hidden;
  background: #000;
}

.image-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 12%, transparent 84%, rgba(255, 255, 255, 0.06)),
    radial-gradient(circle at 50% 6%, rgba(181, 233, 255, 0.11), transparent 34%),
    radial-gradient(circle at 50% 130%, rgba(255, 221, 244, 0.09), transparent 42%),
    radial-gradient(ellipse at center, transparent 52%, rgba(0, 0, 0, 0.28) 100%);
  pointer-events: none;
  z-index: 2;
}

.image-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.16) 0.7px, transparent 1px),
    radial-gradient(rgba(181, 233, 255, 0.08) 0.55px, transparent 0.95px),
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0 1px, rgba(0, 0, 0, 0.14) 1px 2px, rgba(0, 0, 0, 0.025) 2px 4px),
    linear-gradient(90deg, rgba(255, 0, 110, 0.02), transparent 20%, transparent 80%, rgba(0, 255, 255, 0.02));
  background-position: 0 0, 1px 1px, 0 0, 0 0;
  background-size: 2px 2px, 3px 3px, 100% 4px, 100% 100%;
  opacity: 0.5;
  pointer-events: none;
  animation: crtGrain 0.16s steps(2) infinite;
  z-index: 3;
}

.image-stage > * {
  transform: scale(1.01);
  transform-origin: center center;
}

.scene-background,
.scene-sprite {
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

.scene-background {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
  position: relative;
  z-index: 1;
  filter:
    saturate(0.9)
    contrast(1.08)
    brightness(0.95);
}

.scene-sprite {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  max-width: 100%;
  max-height: 68vh;
  object-fit: contain;
}

.scene-sprite.sabine {
  left: 25%;
  bottom: 0;
  width: 34%;
  max-height: 72%;
  transform: translateX(-50%);
  opacity: 0.92;
}

.scene-sprite.niko {
  left: 53%;
  bottom: 0;
  width: 28%;
  max-height: 72%;
  transform: translateX(-50%);
}

.scene-sprite.hidden {
  display: none;
}

.dialogue-box {
  width: 100%;
  height: 154px;
  flex: 1 0 auto;
  background:
    linear-gradient(180deg, rgba(6, 7, 9, 0.98), rgba(0, 0, 0, 0.98)),
    linear-gradient(90deg, rgba(181, 233, 255, 0.04), rgba(255, 221, 244, 0.03));
  border-top: 1px solid rgba(242, 247, 255, 0.16);
  padding: 14px 18px 18px;
  box-shadow:
    0 -1px 0 rgba(181, 233, 255, 0.08),
    0 0 24px rgba(181, 233, 255, 0.04);
  position: relative;
  z-index: 3;
}

.dialogue-speaker {
  margin: 0 0 8px;
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--terminal-dim);
  text-shadow:
    0 0 10px rgba(181, 233, 255, 0.12),
    0 0 18px rgba(255, 221, 244, 0.06);
}

.dialogue-line {
  margin: 0;
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  line-height: 1.5;
  color: var(--terminal-white);
  text-shadow:
    0 0 8px rgba(181, 233, 255, 0.14),
    0 0 14px rgba(255, 221, 244, 0.06);
  background-image: linear-gradient(90deg, var(--terminal-white), #eef6ff 48%, #f7f1ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.dialogue-line.typing::after {
  content: "_";
  display: inline-block;
  margin-left: 2px;
  animation: blink 0.8s step-end infinite;
  color: var(--terminal-white);
}

.scene-background.sabine-frame {
  animation: holoFlicker 5.4s ease-in-out infinite;
  filter:
    saturate(1.03)
    brightness(1.02);
}

.scene-background.sabine-frame::selection {
  background: transparent;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes holoFlicker {
  0%,
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
  8% {
    opacity: 0.985;
  }
  9% {
    opacity: 0.94;
    transform: translate3d(-1px, 0, 0);
  }
  10% {
    opacity: 1;
    transform: translate3d(1px, 0, 0);
  }
  11% {
    transform: translate3d(0, 0, 0);
  }
  56% {
    opacity: 1;
  }
  57% {
    opacity: 0.95;
    transform: translate3d(0, 1px, 0);
  }
  58% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes crtGrain {
  0% {
    transform: translate3d(0, 0, 0);
  }
  25% {
    transform: translate3d(-1px, 0, 0);
  }
  50% {
    transform: translate3d(1px, -1px, 0);
  }
  75% {
    transform: translate3d(0, 1px, 0);
  }
  100% {
    transform: translate3d(0, 0, 0);
  }
}

@media (max-width: 720px) {
  .screen-shell {
    width: 100vw;
    padding: 8px;
  }

  .screen-bezel {
    padding: 10px;
    border-radius: 18px;
  }

  .screen-bezel::before {
    inset: 5px;
    border-radius: 13px;
  }

  .screen-inner {
    width: 100%;
    border-radius: 12px;
  }

  .scene {
    height: 100%;
  }

  .image-stage {
    height: calc(100% - 148px);
  }

  .scene-background,
  .scene-sprite {
    max-height: none;
  }

  .scene-sprite.sabine {
    left: 28%;
    width: 48%;
  }

  .scene-sprite.niko {
    width: 42%;
    left: 54%;
  }

  .dialogue-box {
    height: 148px;
    padding: 12px 14px 16px;
  }

  .dialogue-speaker {
    font-size: 0.88rem;
  }

  .dialogue-line {
    font-size: clamp(1rem, 4vw, 1.15rem);
  }
}
