:root {
  color-scheme: dark;
  font-family:
    "Pretendard",
    "Segoe UI",
    sans-serif;

  background: #07090d;
  color: #effff4;

  --terminal-color: #73ff9c;
  --monitor-color: #b6b3a9;
  --monitor-dark: #6d6b64;
  --screen-color: #020604;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;

  margin: 0;
  padding: 0;

  overflow: hidden;
  background: #07090d;
}

button {
  font: inherit;
}

.crt-app {
  display: grid;
  place-items: center;

  width: 100%;
  height: 100%;

  padding: 18px;

  background:
    radial-gradient(
      circle at center,
      #18201c 0%,
      #090c0a 50%,
      #030403 100%
    );
}

.crt-monitor {
  width: min(100%, 720px);

  padding: 16px 18px 18px;

  background:
    linear-gradient(
      145deg,
      #d1cec3,
      var(--monitor-color) 40%,
      #8b8981
    );

  border: 2px solid #55534e;
  border-radius: 22px;

  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.65),
    inset 2px 2px 3px rgba(255, 255, 255, 0.55),
    inset -4px -4px 8px rgba(0, 0, 0, 0.3);
}

.monitor-top {
  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 0 8px 12px;

  color: #393936;
  font-family: "Courier New", monospace;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.monitor-model {
  color: #55544f;
  font-size: 10px;
}

.bezel {
  padding: 20px;

  background:
    linear-gradient(
      145deg,
      #55544f,
      #252623 50%,
      #75736c
    );

  border-radius: 28px;

  box-shadow:
    inset 8px 8px 16px rgba(0, 0, 0, 0.7),
    inset -4px -4px 10px rgba(255, 255, 255, 0.12);
}

.screen {
  position: relative;

  width: 100%;
  aspect-ratio: 1 / 1;

  overflow: hidden;

  background: var(--screen-color);
  border: 3px solid #161916;
  border-radius: 5% / 4%;

  transform-origin: center;

  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.95),
    0 0 8px rgba(70, 255, 130, 0.12);
}

/* 화면이 켜졌을 때 약한 녹색 발광 */
.screen.is-on {
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.9),
    0 0 18px rgba(70, 255, 130, 0.2);
}

/* 전원을 켤 때 나오는 중앙 흰 선 */
.boot-flash {
  position: absolute;
  z-index: 20;

  top: 50%;
  left: 50%;

  width: 0;
  height: 2px;

  opacity: 0;

  background: #eaffee;

  transform: translate(-50%, -50%);

  box-shadow:
    0 0 8px #ffffff,
    0 0 24px #9effb4,
    0 0 45px #61ff8b;

  pointer-events: none;
}

.screen.is-powering .boot-flash {
  animation: crt-power-on 900ms ease-out forwards;
}

@keyframes crt-power-on {
  0% {
    width: 0;
    height: 2px;
    opacity: 0;
  }

  15% {
    width: 12%;
    height: 2px;
    opacity: 1;
  }

  42% {
    width: 100%;
    height: 2px;
    opacity: 1;
  }

  68% {
    width: 100%;
    height: 4px;
    opacity: 1;
  }

  86% {
    width: 100%;
    height: 100%;
    opacity: 0.75;
  }

  100% {
    width: 100%;
    height: 100%;
    opacity: 0;
  }
}

.screen-content {
  position: absolute;
  inset: 0;
  z-index: 4;

  overflow: hidden;
}

/* CRT 잡음 */

.static-layer {
  position: absolute;
  z-index: 7;
  inset: -30%;

  opacity: 0;

  background-image:
    repeating-radial-gradient(
      circle at 10% 20%,
      rgba(255, 255, 255, 0.35) 0,
      rgba(255, 255, 255, 0.35) 1px,
      rgba(0, 0, 0, 0.2) 1px,
      rgba(0, 0, 0, 0.2) 3px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.08) 0,
      rgba(255, 255, 255, 0.08) 1px,
      transparent 1px,
      transparent 4px
    );

  background-size:
    8px 8px,
    11px 11px;

  mix-blend-mode: screen;

  pointer-events: none;
}

.screen.show-static .static-layer {
  opacity: 0.38;
  animation: static-noise 90ms steps(2) infinite;
}

@keyframes static-noise {
  0% {
    transform: translate(-2%, -1%);
  }

  25% {
    transform: translate(2%, 1%);
  }

  50% {
    transform: translate(-1%, 3%);
  }

  75% {
    transform: translate(3%, -2%);
  }

  100% {
    transform: translate(-3%, 2%);
  }
}

/* 부팅 로그 */

.terminal {
  position: absolute;
  inset: 0;

  padding: 24px;

  opacity: 0;

  color: var(--terminal-color);
  background:
    radial-gradient(
      circle at center,
      rgba(18, 58, 30, 0.24),
      transparent 70%
    );

  font-family:
    "Courier New",
    monospace;

  text-shadow:
    0 0 5px rgba(88, 255, 135, 0.9),
    0 0 12px rgba(88, 255, 135, 0.25);

  transition: opacity 180ms linear;
}

.screen.show-terminal .terminal {
  opacity: 1;
}

.screen.terminal-done .terminal {
  opacity: 0;
}

.terminal-title {
  margin-bottom: 18px;
  padding-bottom: 8px;

  border-bottom: 1px solid rgba(115, 255, 156, 0.35);

  font-size: clamp(13px, 2.2vw, 19px);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.boot-log {
  overflow: hidden;

  max-height: calc(100% - 60px);

  font-size: clamp(11px, 1.9vw, 16px);
  line-height: 1.55;
  white-space: pre-wrap;
}

.boot-line {
  min-height: 1.55em;
}

.boot-line.success {
  color: #d5ffe0;
}

.boot-line.warning {
  color: #ffe675;
  text-shadow:
    0 0 5px rgba(255, 226, 90, 0.75);
}

.terminal-cursor {
  display: inline-block;

  width: 9px;
  height: 1.1em;

  margin-top: 4px;

  vertical-align: text-bottom;

  background: var(--terminal-color);

  animation: cursor-blink 600ms steps(1) infinite;
}

@keyframes cursor-blink {
  0%,
  49% {
    opacity: 1;
  }

  50%,
  100% {
    opacity: 0;
  }
}

/* 이미지 */

.image-layer {
  position: absolute;
  inset: 0;

  opacity: 0;
  overflow: hidden;

  background: #020403;

  pointer-events: none;
}

.image-layer img {
  display: block;

  width: 100%;
  height: 100%;

  object-fit: contain;
  object-position: center;

  filter:
    brightness(0.18)
    contrast(2.2)
    saturate(0)
    blur(8px);

  transform: scale(1.06);

  transition:
    filter 1.5s ease,
    transform 1.5s ease;
}

.screen.show-image .image-layer {
  opacity: 1;
  animation: image-appear 1.6s ease forwards;
}

.screen.show-image .image-layer img {
  filter:
    brightness(1)
    contrast(1)
    saturate(1)
    blur(0);

  transform: scale(1);
}

@keyframes image-appear {
  0% {
    opacity: 0;
  }

  12% {
    opacity: 0.7;
  }

  18% {
    opacity: 0.15;
  }

  27% {
    opacity: 0.95;
  }

  34% {
    opacity: 0.45;
  }

  45%,
  100% {
    opacity: 1;
  }
}

/* 글리치 */

.screen.glitch .image-layer {
  animation:
    image-appear 1.6s ease forwards,
    image-glitch 120ms steps(2) infinite;
}

@keyframes image-glitch {
  0% {
    clip-path: inset(0 0 0 0);
    transform: translate(0);
  }

  20% {
    clip-path: inset(12% 0 63% 0);
    transform: translate(-7px, 0);
  }

  40% {
    clip-path: inset(58% 0 16% 0);
    transform: translate(8px, 0);
  }

  60% {
    clip-path: inset(33% 0 41% 0);
    transform: translate(-4px, 0);
  }

  80% {
    clip-path: inset(73% 0 5% 0);
    transform: translate(5px, 0);
  }

  100% {
    clip-path: inset(0 0 0 0);
    transform: translate(0);
  }
}

.image-information {
  position: absolute;
  top: 14px;
  right: 16px;
  left: 16px;

  display: flex;
  justify-content: space-between;

  opacity: 0;

  color: rgba(185, 255, 206, 0.82);

  font-family: "Courier New", monospace;
  font-size: clamp(9px, 1.5vw, 12px);
  letter-spacing: 0.08em;

  text-shadow: 0 0 6px rgba(70, 255, 120, 0.8);
}

.screen.is-online .image-information {
  opacity: 1;
  transition: opacity 500ms ease;
}

.online-label {
  position: absolute;

  right: 20px;
  bottom: 20px;

  padding: 8px 12px;

  opacity: 0;

  color: #a8ffbd;
  background: rgba(0, 20, 7, 0.76);
  border: 1px solid rgba(114, 255, 151, 0.55);

  font-family: "Courier New", monospace;
  font-size: clamp(11px, 2vw, 16px);
  font-weight: 700;
  letter-spacing: 0.08em;

  box-shadow:
    0 0 14px rgba(72, 255, 121, 0.18);

  transform: translateY(8px);
}

.screen.is-online .online-label {
  opacity: 1;
  transform: translateY(0);

  transition:
    opacity 400ms ease,
    transform 400ms ease;
}

/* 스캔라인 */

.scanlines {
  position: absolute;
  z-index: 10;
  inset: 0;

  opacity: 0;

  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.035) 0,
      rgba(255, 255, 255, 0.035) 1px,
      rgba(0, 0, 0, 0.11) 1px,
      rgba(0, 0, 0, 0.11) 4px
    );

  pointer-events: none;
}

.screen.is-on .scanlines {
  opacity: 1;
}

.vignette {
  position: absolute;
  z-index: 11;
  inset: 0;

  background:
    radial-gradient(
      ellipse at center,
      transparent 55%,
      rgba(0, 0, 0, 0.48) 100%
    );

  pointer-events: none;
}

/* 전원 종료 효과 */

.screen.is-shutting-down {
  animation: crt-power-off 480ms ease-in forwards;
}

@keyframes crt-power-off {
  0% {
    transform: scale(1, 1);
    filter: brightness(1);
  }

  55% {
    transform: scale(1, 0.012);
    filter: brightness(2.8);
  }

  75% {
    transform: scale(0.3, 0.008);
    filter: brightness(4);
  }

  100% {
    transform: scale(0, 0);
    filter: brightness(0);
  }
}

/* 하단 버튼 영역 */

.monitor-controls {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 10px;
  align-items: center;

  padding: 16px 8px 0;
}

.control-button {
  min-height: 42px;
  padding: 0 16px;

  color: #e5e3da;
  background:
    linear-gradient(
      to bottom,
      #55544f,
      #343531
    );

  border: 1px solid #1e1f1d;
  border-radius: 7px;

  font-family: "Courier New", monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;

  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.35);

  cursor: pointer;
}

.control-button:hover:not(:disabled) {
  filter: brightness(1.12);
}

.control-button:active:not(:disabled) {
  transform: translateY(1px);
}

.control-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.power-button {
  display: inline-flex;
  gap: 9px;
  align-items: center;
}

.power-led {
  width: 10px;
  height: 10px;

  background: #421313;
  border: 1px solid #251111;
  border-radius: 50%;

  box-shadow:
    inset 0 0 3px rgba(0, 0, 0, 0.8);
}

.power-led.is-on {
  background: #57ff80;

  box-shadow:
    0 0 5px #57ff80,
    0 0 12px rgba(87, 255, 128, 0.75);
}

.power-led.is-working {
  background: #ffd95c;

  box-shadow:
    0 0 5px #ffd95c,
    0 0 12px rgba(255, 217, 92, 0.7);

  animation: led-pulse 450ms ease-in-out infinite alternate;
}

@keyframes led-pulse {
  from {
    opacity: 0.45;
  }

  to {
    opacity: 1;
  }
}

.system-status {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;

  min-width: 0;

  color: #575750;

  font-family: "Courier New", monospace;
  font-size: 11px;
}

.system-status strong {
  overflow: hidden;

  color: #343531;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .crt-app {
    padding: 8px;
  }

  .crt-monitor {
    padding: 10px;
    border-radius: 14px;
  }

  .bezel {
    padding: 12px;
    border-radius: 18px;
  }

  .terminal {
    padding: 16px;
  }

  .monitor-controls {
    grid-template-columns: 1fr 1fr;
  }

  .control-button {
    padding: 0 10px;
  }

  .system-status {
    grid-column: 1 / -1;
    justify-content: center;
  }
}