:root {
  --bg: #050505;
  --card: #0a0a0a;
  --pink: #ec4899;
  --green: #10b981;
  --gray: #8a8a8a;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --stencil: "Oswald", Impact, "Arial Narrow Bold", sans-serif;
}

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

html, body { min-height: 100%; }

body {
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 45% at 50% 0%, rgba(168, 85, 247, 0.28), rgba(236, 72, 153, 0.12) 45%, transparent 75%),
    linear-gradient(rgba(236, 72, 153, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(236, 72, 153, 0.06) 1px, transparent 1px);
  background-size: 100% 100%, 20px 20px, 20px 20px;
  background-attachment: fixed;
  color: #fff;
  font-family: var(--mono);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */
.header { text-align: center; margin-bottom: 28px; }

.brand {
  color: var(--pink);
  font-family: var(--mono);
  font-size: clamp(14px, 4.2vw, 18px);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(236, 72, 153, 0.55);
  animation: flicker 6s infinite;
}

.tagline { color: var(--gray); font-size: 12px; margin-top: 6px; letter-spacing: 0.04em; }

/* ---------- Card ---------- */
.card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 2px solid var(--pink);
  box-shadow: 0 0 30px rgba(236, 72, 153, 0.18), 6px 6px 0 rgba(236, 72, 153, 0.25);
  padding: 32px 22px 22px;
  text-align: center;
}

.tape {
  position: absolute;
  top: -12px;
  width: 92px;
  height: 26px;
  background: rgba(200, 200, 200, 0.28);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  filter: blur(0.4px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  /* torn edges */
  clip-path: polygon(0 8%, 6% 0, 12% 10%, 20% 2%, 30% 8%, 42% 0, 55% 6%, 68% 0, 80% 8%, 90% 0, 100% 6%,
                     100% 92%, 94% 100%, 84% 92%, 72% 100%, 60% 94%, 48% 100%, 36% 92%, 24% 100%, 12% 94%, 4% 100%, 0 92%);
}
.tape--left { left: -24px; transform: rotate(-35deg); }
.tape--right { right: -24px; transform: rotate(35deg); }

.device__icon { font-size: 44px; line-height: 1; filter: drop-shadow(0 0 10px rgba(16, 185, 129, 0.35)); }
.device__label { color: var(--gray); font-size: 12px; letter-spacing: 0.2em; margin-top: 8px; }

.status {
  margin: 20px auto 0;
  padding: 8px 12px;
  border: 2px dashed var(--green);
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: rgba(16, 185, 129, 0.06);
}
.status.is-error {
  border-color: var(--pink);
  color: var(--pink);
  background: rgba(236, 72, 153, 0.08);
}

/* ---------- Glitch title (torn VHS) ---------- */
.title {
  position: relative;
  margin: 22px 0 14px;
  font-family: Impact, "Haettenschweiler", "Oswald", "Arial Narrow Bold", sans-serif;
  font-weight: 400;
  font-size: clamp(32px, 10vw, 44px);
  line-height: 1.05;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #fff;
  /* pink shadow pushed left/down + soft VHS bleed */
  text-shadow:
    -4px 4px 0 var(--pink),
    -6px 6px 6px rgba(236, 72, 153, 0.45),
    2px -1px 2px rgba(34, 211, 238, 0.35);
  transform: skewX(-7deg);
  filter: blur(0.35px);
  animation: vhs-jitter 3.2s infinite steps(1);
}
/* Torn strips: copies of the text that mask the original slice
   with the card color and sit displaced sideways. */
.title::before,
.title::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: var(--card);
  color: #fff;
  text-shadow: -4px 4px 0 var(--pink), -6px 6px 6px rgba(236, 72, 153, 0.45);
}
.title::before {
  clip-path: inset(0 0 64% 0);
  transform: translateX(-5px);
  animation: tear-top 2.7s infinite steps(1);
}
.title::after {
  clip-path: inset(56% 0 20% 0);
  transform: translateX(6px) skewX(-6deg);
  filter: blur(0.6px);
  animation: tear-bottom 3.4s infinite steps(1);
}

.hint { color: var(--gray); font-size: 12px; line-height: 1.55; margin-bottom: 20px; text-align: left; }

/* ---------- Buttons ---------- */
.btn {
  display: block;
  width: 100%;
  padding: 16px 12px;
  font-family: var(--mono);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translate(3px, 3px); }

.btn--primary {
  background: var(--pink);
  color: #fff;
  border: 3px solid #fff;
  font-size: 20px;
  box-shadow: 0 0 24px rgba(236, 72, 153, 0.7), 5px 5px 0 #fff2;
  animation: pulse 2.4s ease-in-out infinite;
}
.btn--primary:hover { filter: brightness(1.1); }
.btn--primary.is-disabled {
  background: #2a2a2a;
  color: #777;
  border-color: #444;
  box-shadow: none;
  animation: none;
  pointer-events: none;
}

.btn--secondary {
  margin-top: 12px;
  background: #fff;
  color: #000;
  border: 2px solid #000;
  outline: 2px solid #fff;
  outline-offset: -6px;
  font-size: 15px;
  padding: 13px 12px;
}
.btn--secondary:hover { background: #f3f3f3; }

/* ---------- Terminal ---------- */
.terminal {
  margin-top: 20px;
  padding: 12px;
  background: #000;
  border: 1px solid #333;
  border-left: 3px solid var(--pink);
  font-size: 11px;
  text-align: left;
  line-height: 1.5;
  word-break: break-all;
  overflow: hidden;
}
.terminal__prompt { color: var(--pink); font-weight: 700; margin-right: 6px; }
.terminal__cmd { color: #e5e5e5; }
.cursor { color: var(--pink); animation: blink 1s steps(1) infinite; }

/* ---------- Footer ---------- */
.footer { margin-top: 22px; text-align: center; }
.footer__link {
  background: none;
  border: none;
  color: var(--gray);
  font-family: var(--mono);
  font-size: 12px;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: pointer;
}
.footer__link:hover { color: #fff; }
.footer__note { color: var(--green); font-size: 11px; margin-top: 8px; max-width: 360px; line-height: 1.5; }

/* ---------- Animations ---------- */
@keyframes blink { 50% { opacity: 0; } }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 18px rgba(236, 72, 153, 0.55), 5px 5px 0 #fff2; }
  50% { box-shadow: 0 0 34px rgba(236, 72, 153, 0.95), 5px 5px 0 #fff2; }
}

@keyframes flicker {
  0%, 92%, 100% { opacity: 1; }
  93% { opacity: 0.4; }
  94% { opacity: 1; }
  96% { opacity: 0.6; }
}

@keyframes vhs-jitter {
  0%, 100% { transform: skewX(-7deg); }
  46% { transform: skewX(-7deg) translateX(2px); }
  47% { transform: skewX(-12deg) translateX(-3px); }
  48% { transform: skewX(-7deg); }
  83% { transform: skewX(-4deg) translateX(1px); }
  84% { transform: skewX(-7deg); }
}
@keyframes tear-top {
  0%, 100% { transform: translateX(-5px); clip-path: inset(0 0 64% 0); }
  31% { transform: translateX(-9px); clip-path: inset(0 0 60% 0); }
  33% { transform: translateX(-5px); clip-path: inset(0 0 64% 0); }
  71% { transform: translateX(3px); clip-path: inset(4% 0 58% 0); color: #22d3ee; }
  73% { transform: translateX(-5px); clip-path: inset(0 0 64% 0); color: #fff; }
}
@keyframes tear-bottom {
  0%, 100% { transform: translateX(6px) skewX(-6deg); clip-path: inset(56% 0 20% 0); }
  22% { transform: translateX(11px) skewX(-10deg); clip-path: inset(52% 0 26% 0); }
  24% { transform: translateX(6px) skewX(-6deg); clip-path: inset(56% 0 20% 0); }
  64% { transform: translateX(-4px) skewX(-3deg); clip-path: inset(62% 0 14% 0); color: var(--pink); }
  66% { transform: translateX(6px) skewX(-6deg); clip-path: inset(56% 0 20% 0); color: #fff; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}

/* Small iPhones (SE / mini) */
@media (max-width: 380px) {
  .card { padding: 28px 16px 18px; }
  .header { margin-bottom: 22px; }
  .btn--primary { font-size: 18px; padding: 14px 10px; }
  .btn--secondary { font-size: 14px; }
  .tape { width: 76px; height: 22px; }
  .tape--left { left: -18px; }
  .tape--right { right: -18px; }
}
