.shi8-widget {
  position: relative;
  width: 100%;
  max-width: 100%;
  color: var(--shi8-text, #9ef35c);
  font-family: 'DotGothic16', monospace;
}

.shi8-widget .shi8-screen {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at top, rgba(255, 255, 255, 0.06), transparent 56%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.1)),
    var(--shi8-bg, #070d0a);
  border-radius: var(--shi8-radius, 8px);
  padding: var(--shi8-padding, 18px 22px);
  min-height: 120px;
}

.shi8-widget.has-frame .shi8-screen {
  border: 2px solid var(--shi8-accent, #57ffb3);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.45) inset,
    0 0 24px rgba(0, 0, 0, 0.24),
    0 0 40px var(--shi8-accent, #57ffb3);
}

.shi8-widget .shi8-grid,
.shi8-widget .shi8-scanlines,
.shi8-widget .shi8-noise {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.shi8-widget .shi8-grid {
  opacity: var(--shi8-grid-opacity, 0.16);
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.15) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.15) 1px, transparent 1px);
  background-size: 10px 10px;
}

.shi8-widget .shi8-scanlines {
  opacity: var(--shi8-scanline-opacity, 0.24);
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.7) 0,
    rgba(0, 0, 0, 0.7) 1px,
    rgba(255, 255, 255, 0.04) 1px,
    rgba(255, 255, 255, 0.04) 3px
  );
  mix-blend-mode: soft-light;
}

.shi8-widget .shi8-noise {
  opacity: var(--shi8-noise-opacity, 0.08);
  background-image: radial-gradient(circle at 24% 18%, rgba(255, 255, 255, 0.95) 0.5px, transparent 1px);
  background-size: 4px 4px;
}

.shi8-widget .shi8-content {
  position: relative;
  z-index: 2;
}

.shi8-widget .pixelated-text {
  margin: 0;
  display: inline-block;
  position: relative;
  color: var(--shi8-text, #9ef35c);
  font-size: var(--shi8-font-size, 28px);
  line-height: 1.05;
  white-space: pre-wrap;
  image-rendering: pixelated;
  letter-spacing: var(--shi8-letter, 1px);
  text-shadow:
    0 0 calc(10px * var(--shi8-glow, 0.48)) var(--shi8-accent, #57ffb3),
    0 0 calc(26px * var(--shi8-glow, 0.48)) var(--shi8-accent, #57ffb3);
}

.shi8-widget .shi8-main::before,
.shi8-widget .shi8-main::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.shi8-widget.is-animated .shi8-main::before,
.shi8-widget.is-animated .shi8-main::after {
  opacity: 0.72;
}

.shi8-widget.is-animated .shi8-main::before {
  color: #56cfff;
  transform: translateX(calc(var(--shi8-glitch, 2px) * -1));
  animation: shi8-glitch-a var(--shi8-glitch-a-duration, 1.2s) steps(1, end) infinite;
}

.shi8-widget.is-animated .shi8-main::after {
  color: #ff4b9e;
  transform: translateX(var(--shi8-glitch, 2px));
  animation: shi8-glitch-b var(--shi8-glitch-b-duration, 1.6s) steps(1, end) infinite;
}

.shi8-widget .shi8-subtext {
  margin-top: 16px;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--shi8-text, #9ef35c);
  opacity: 0.88;
  text-transform: uppercase;
}

.shi8-widget.has-cursor .shi8-subtext::after {
  content: '_';
  margin-left: 6px;
  color: var(--shi8-accent, #57ffb3);
}

.shi8-widget.is-animated.has-cursor .shi8-subtext::after {
  animation: shi8-cursor var(--shi8-cursor-duration, 0.9s) steps(1, end) infinite;
}

.shi8-widget.is-animated .shi8-screen {
  animation: shi8-flicker var(--shi8-flicker-duration, 1.75s) steps(1, end) infinite;
}

.shi8-widget.is-animated .shi8-noise {
  animation: shi8-noise var(--shi8-noise-duration, 0.875s) steps(8, end) infinite;
}

.shi8-widget.is-animated .shi8-scanlines {
  animation: shi8-scanline-drift calc(var(--shi8-noise-duration, 0.875s) * 2) linear infinite;
}

.shi8-widget.shi8-preset-neon_pink .shi8-grid,
.shi8-widget.shi8-preset-blue_console .shi8-grid {
  background-size: 12px 12px;
}

.shi8-widget.no-frame .shi8-screen {
  box-shadow: none;
  border: 0;
}

@keyframes shi8-cursor {
  0%, 49% {
    opacity: 1;
  }
  50%, 100% {
    opacity: 0;
  }
}

@keyframes shi8-noise {
  0% {
    transform: translate(0, 0);
  }
  20% {
    transform: translate(-1px, 1px);
  }
  40% {
    transform: translate(1px, -1px);
  }
  60% {
    transform: translate(-1px, -1px);
  }
  80% {
    transform: translate(1px, 1px);
  }
  100% {
    transform: translate(0, 0);
  }
}

@keyframes shi8-flicker {
  0% {
    filter: brightness(1);
  }
  10% {
    filter: brightness(calc(1 - (0.08 * var(--shi8-flicker, 0.36))));
  }
  14% {
    filter: brightness(calc(1 + (0.12 * var(--shi8-flicker, 0.36))));
  }
  28% {
    filter: brightness(calc(1 - (0.06 * var(--shi8-flicker, 0.36))));
  }
  62% {
    filter: brightness(calc(1 + (0.08 * var(--shi8-flicker, 0.36))));
  }
  100% {
    filter: brightness(1);
  }
}

@keyframes shi8-glitch-a {
  0%, 74%, 100% {
    clip-path: inset(0 0 0 0);
  }
  75% {
    clip-path: inset(5% 0 72% 0);
  }
  79% {
    clip-path: inset(44% 0 36% 0);
  }
  83% {
    clip-path: inset(72% 0 4% 0);
  }
}

@keyframes shi8-glitch-b {
  0%, 68%, 100% {
    clip-path: inset(0 0 0 0);
  }
  69% {
    clip-path: inset(10% 0 66% 0);
  }
  73% {
    clip-path: inset(56% 0 26% 0);
  }
  77% {
    clip-path: inset(80% 0 2% 0);
  }
}

@keyframes shi8-scanline-drift {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 0 6px;
  }
}
