:root {
  color-scheme: dark;
  --shell-black: #010403;
  --screen-black: #020806;
  --screen-green: #3dffae;
  --screen-cyan: #60ffd4;
  --screen-white: #efffe7;
  --frame-edge: #17201c;
  --frame-highlight: #26332d;
  --control-bg: rgba(0, 11, 8, 0.74);
  --control-border: rgba(75, 255, 182, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: #000;
}

body {
  overflow: hidden;
  font-family: "Courier New", Courier, monospace;
  color: var(--screen-green);
}

button,
textarea {
  font: inherit;
}

button {
  appearance: none;
}

.app-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(8px, 2.1vw, 28px);
  background:
    radial-gradient(circle at 50% 42%, rgba(20, 45, 34, 0.12), transparent 48%),
    linear-gradient(180deg, #040706 0%, #000 88%);
}

.terminal-frame {
  position: relative;
  width: min(96vw, 1280px);
  aspect-ratio: 16 / 9;
  max-height: 94svh;
  padding: clamp(8px, 1.4vw, 18px);
  border: 1px solid #1b2520;
  border-radius: clamp(14px, 2.2vw, 34px);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.045), transparent 28%),
    linear-gradient(315deg, rgba(255, 255, 255, 0.018), transparent 38%),
    #060a08;
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.72),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    inset 0 -12px 35px rgba(0, 0, 0, 0.7);
}

.screen-bezel {
  position: absolute;
  inset: 5px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.025),
    inset 0 0 24px rgba(0, 0, 0, 0.86);
}

.terminal-screen {
  position: relative;
  width: 100%;
  height: calc(100% - clamp(24px, 3vw, 38px));
  overflow: hidden;
  isolation: isolate;
  border-radius: clamp(10px, 1.5vw, 24px);
  background:
    radial-gradient(ellipse at 50% 47%, rgba(18, 64, 43, 0.10), transparent 55%),
    #010705;
  box-shadow:
    inset 0 0 45px rgba(0, 0, 0, 0.9),
    inset 0 0 4px rgba(107, 255, 198, 0.13),
    0 0 0 1px rgba(0, 0, 0, 0.96);
  transform: translateZ(0);
}

.terminal-screen::before,
.terminal-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.terminal-screen::before {
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(205, 255, 231, 0.020) 0,
      rgba(205, 255, 231, 0.020) 1px,
      rgba(0, 10, 7, 0.026) 2px,
      rgba(0, 10, 7, 0.026) 4px
    );
  mix-blend-mode: screen;
  opacity: 0.84;
}

.terminal-screen::after {
  inset: -6%;
  background:
    radial-gradient(ellipse at center, transparent 42%, rgba(0, 0, 0, 0.32) 74%, rgba(0, 0, 0, 0.76) 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.17), transparent 12%, transparent 88%, rgba(0, 0, 0, 0.19));
}

#terminal-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 1;
  outline: none;
}

.screen-reflection {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    linear-gradient(118deg, rgba(255, 255, 255, 0.024), transparent 24%),
    radial-gradient(ellipse at 52% -20%, rgba(180, 255, 222, 0.035), transparent 38%);
  opacity: 0.8;
}

.scanline-band {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  height: 18%;
  top: -20%;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(98, 255, 196, 0.018) 38%,
    rgba(98, 255, 196, 0.055) 50%,
    rgba(98, 255, 196, 0.018) 62%,
    transparent
  );
  animation: scanline-drift 9s linear infinite;
  mix-blend-mode: screen;
}

.terminal-controls {
  position: absolute;
  z-index: 7;
  top: clamp(8px, 1.1vw, 14px);
  right: clamp(8px, 1.1vw, 14px);
  display: flex;
  gap: 6px;
  opacity: 0.16;
  transition: opacity 160ms ease;
}

.terminal-screen:hover .terminal-controls,
.terminal-controls:focus-within {
  opacity: 0.92;
}

.terminal-controls button {
  min-height: 28px;
  padding: 5px 8px;
  border: 1px solid var(--control-border);
  border-radius: 2px;
  background: var(--control-bg);
  color: rgba(122, 255, 203, 0.76);
  font-size: clamp(8px, 0.72vw, 11px);
  line-height: 1;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: inset 0 0 8px rgba(54, 255, 174, 0.035);
}

.terminal-controls button:hover,
.terminal-controls button:focus-visible {
  color: var(--screen-white);
  border-color: rgba(126, 255, 209, 0.58);
  outline: none;
  box-shadow: 0 0 10px rgba(47, 255, 172, 0.16);
}

.audio-notice {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: 4.5%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 88%;
  padding: 6px 10px;
  border: 1px solid rgba(63, 255, 178, 0.16);
  background: rgba(0, 7, 5, 0.74);
  color: rgba(72, 255, 181, 0.62);
  font-size: clamp(9px, 0.85vw, 12px);
  letter-spacing: 0.09em;
  text-align: center;
  transition: opacity 280ms ease, transform 280ms ease;
  pointer-events: none;
}

.audio-notice.is-hidden {
  opacity: 0;
  transform: translate(-50%, 6px);
}

#terminal-input {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.terminal-footer {
  height: clamp(24px, 3vw, 38px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(3px, 0.5vw, 8px);
  color: rgba(88, 122, 104, 0.55);
  font-size: clamp(8px, 0.72vw, 11px);
  letter-spacing: 0.1em;
  user-select: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes scanline-drift {
  from { transform: translateY(0); }
  to { transform: translateY(680%); }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 0;
  }

  .terminal-frame {
    width: 100vw;
    max-height: none;
    border-radius: 0;
    border: 0;
    padding: 4px;
  }

  .terminal-screen {
    border-radius: 4px;
  }

  .terminal-controls {
    left: 8px;
    right: 8px;
    top: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .terminal-controls button {
    min-height: 26px;
    padding: 4px 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scanline-band {
    animation: none;
    display: none;
  }

  .terminal-controls,
  .audio-notice {
    transition: none;
  }
}
