:root {
      --teal: #00d1b2;
      --teal-bright: #00fff2;
      --bg: #0b0b0b;
      --panel: #171717;
      --panel-2: #242424;
      --text: #e8e8e8;
      --red-bg: #ff0808;
      --blue-bg: #001eff;
      --glitch-blue: #00ccff;
      --glitch-red: #ff3333;
      --green: #00ff00;
    }

    * { box-sizing: border-box; }

    html, body {
      margin: 0;
      min-height: 100%;
      font-family: monospace;
      background: var(--bg);
      color: var(--text);
    }

    body.locked { overflow: hidden; }

    .page {
      display: none;
      min-height: 100vh;
      min-height: 100dvh;
      width: 100%;
      background: var(--bg);
    }

    .page.active { display: block; }

    .site-shell, .simple-page {
      width: min(980px, calc(100% - 2rem));
      margin: 0 auto;
      padding: 2rem 0;
    }

    header, footer {
      background: var(--panel);
      text-align: center;
      padding: 1.4rem 1rem;
    }

    header h1 {
      margin: 0;
      color: var(--teal);
      font-size: clamp(1.45rem, 4vw, 2rem);
    }

    header p {
      margin: 1rem 0 0;
      color: #ffffff;
    }

    .hero {
      text-align: center;
      padding: 3rem 1rem;
      background: linear-gradient(to right, #2f2f2f, #4a4a4a);
    }

    .hero p {
      max-width: 720px;
      margin: 0 auto;
      line-height: 1.45;
      font-size: clamp(1rem, 2.4vw, 1.2rem);
    }

    .cta {
      display: flex;
      flex-wrap: wrap;
      gap: 1rem;
      justify-content: center;
      margin-top: 1.4rem;
    }

    button {
      appearance: none;
      border: 0;
      border-radius: 5px;
      background: var(--teal);
      color: #050505;
      padding: 0.8rem 1.45rem;
      font-family: monospace;
      font-weight: bold;
      cursor: pointer;
      position: relative;
      z-index: 20;
      min-width: 120px;
      transition: transform 120ms ease, filter 120ms ease;
      pointer-events: auto;
      user-select: none;
    }

    button:hover {
      filter: brightness(1.1);
      transform: translateY(-1px);
    }

    button:active { transform: translateY(1px); }

    button:disabled {
      cursor: wait;
      filter: grayscale(0.35) brightness(0.75);
      transform: none;
    }

    .top-login {
      position: fixed !important;
      top: 0.75rem;
      right: 0.85rem;
      bottom: auto;
      left: auto;
      z-index: 1001;
      appearance: none;
      border: 0;
      background: transparent;
      color: var(--green);
      padding: 0;
      min-width: 0;
      width: auto;
      height: auto;
      font-family: monospace;
      font-size: 0.78rem;
      font-weight: normal;
      line-height: 1;
      text-decoration: none;
      cursor: pointer;
      transform: none !important;
      transition: color 120ms ease, filter 120ms ease;
    }

    .top-login:hover {
      filter: brightness(1.25);
      transform: none !important;
      text-decoration: underline;
    }

    .top-login:active {
      transform: none !important;
    }

    .content-block {
      padding: 2rem 0 0;
      line-height: 1.5;
    }

    .content-block h2,
    .simple-card h2,
    .detail-grid h3 {
      color: var(--teal);
    }

    .content-block h2 {
      margin: 0 0 1rem;
      font-size: 1.35rem;
    }

    .content-block p { margin: 0; }

    .content-block ul,
    .simple-card ul {
      margin: 0;
      padding-left: 2rem;
    }

    footer { margin-top: 2.5rem; }
    footer p { margin: 0; }

    footer button {
      margin-left: 0.5rem;
      padding: 0.55rem 1rem;
      min-width: auto;
    }

    .simple-card {
      background: var(--panel);
      border: 1px solid #333;
      padding: 2rem;
      line-height: 1.55;
      margin-top: 1rem;
    }

    .detail-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 1rem;
      margin-top: 1.25rem;
    }

    .detail-box {
      background: var(--panel-2);
      border: 1px solid #3a3a3a;
      padding: 1rem;
    }

    .detail-box h3 { margin-top: 0; }
    .detail-box p { margin-bottom: 0; }

    .subscribe-panel {
      margin-top: 1.5rem;
      padding: 1rem;
      background: #101010;
      border: 1px solid #333;
    }

    .subscribe-panel h3 {
      margin: 0 0 0.75rem;
      color: var(--teal);
    }

    .subscribe-form {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 0.75rem;
    }

    .subscribe-form input {
      flex: 1 1 260px;
      min-width: 0;
      border: 1px solid #444;
      border-radius: 5px;
      background: #050505;
      color: var(--text);
      padding: 0.78rem 0.9rem;
      font-family: monospace;
      font-size: 1rem;
    }

    .subscribe-form input:focus {
      outline: 2px solid rgba(0, 209, 178, 0.55);
      outline-offset: 2px;
    }

    .subscribe-spinner {
      display: none;
      width: 22px;
      height: 22px;
      border: 3px solid var(--teal);
      border-top-color: transparent;
      border-radius: 50%;
      animation: smallSpin 0.8s linear infinite;
    }

    .subscribe-spinner.active { display: inline-block; }

    .subscribe-error {
      min-height: 1.4em;
      margin: 0.75rem 0 0;
      color: #ff3333;
      font-weight: bold;
    }

    @keyframes smallSpin {
      to { transform: rotate(360deg); }
    }

    .login-form {
      display: grid;
      gap: 1rem;
      margin-top: 1rem;
    }

    .login-field {
      display: grid;
      gap: 0.4rem;
    }

    .login-field label {
      color: var(--teal);
      font-weight: bold;
    }

    .login-field input {
      width: 100%;
      border: 1px solid #444;
      border-radius: 5px;
      background: #050505;
      color: var(--text);
      padding: 0.8rem 0.9rem;
      font-family: monospace;
      font-size: 1rem;
    }

    .login-field input:focus {
      outline: 2px solid rgba(0, 209, 178, 0.55);
      outline-offset: 2px;
    }

    .login-actions {
      display: flex;
      justify-content: space-between;
      gap: 1rem;
      margin-top: 0.4rem;
    }

    .login-status {
      min-height: 1.4em;
      margin: 0.25rem 0 0;
      font-weight: bold;
    }

    .login-status.error { color: #ff3333; }
    .login-status.success { color: var(--green); }

    body.login-pending,
    body.login-pending * {
      cursor: wait !important;
    }

    .restricted-output {
      margin-top: 1rem;
      padding: 1.25rem;
      background: #050505;
      border: 1px solid #333;
      color: var(--text);
      font-size: 0.95rem;
      line-height: 1.55;
      overflow-wrap: break-word;
    }

    .dashboard-intro {
      margin: 0 0 1rem;
    }

    .dashboard-nav {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 0.75rem;
      margin: 1rem 0 1.25rem;
    }

    .dashboard-nav button,
    .dashboard-actions button {
      min-width: 0;
      width: 100%;
    }

    .dashboard-section {
      border-top: 1px solid #333;
      padding-top: 1rem;
    }

    .dashboard-section h3 {
      margin: 0 0 0.5rem;
      color: var(--teal);
      font-size: 1.2rem;
    }

    .dashboard-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 0.75rem;
      margin-top: 1rem;
    }

    .dashboard-card {
      background: var(--panel-2);
      border: 1px solid #3a3a3a;
      padding: 1rem;
    }

    .dashboard-card h4 {
      margin: 0 0 0.5rem;
      color: var(--teal-bright);
      font-size: 1rem;
    }

    .dashboard-card p {
      margin: 0;
    }

    .dashboard-card button {
      margin-top: 0.75rem;
      width: 100%;
    }

    .dashboard-list {
      margin: 0.9rem 0 0;
      padding-left: 1.35rem;
    }

    .dashboard-warning {
      margin-top: 1rem;
      color: #ff3333;
      font-weight: bold;
    }

    .status-row {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 0.75rem;
      margin: 1rem 0 1.25rem;
    }

    .status-card {
      background: #101010;
      border: 1px solid #333;
      padding: 0.85rem;
    }

    .status-card span {
      display: block;
      color: #9a9a9a;
      font-size: 0.78rem;
      margin-bottom: 0.25rem;
    }

    .status-card strong {
      color: var(--teal-bright);
      font-size: 1rem;
    }

    .dashboard-actions {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 0.75rem;
      margin-top: 1rem;
    }

    .workspace-shell {
      display: grid;
      grid-template-columns: 220px minmax(0, 1fr);
      gap: 1rem;
      margin-top: 1rem;
    }

    .workspace-sidebar {
      display: grid;
      align-content: start;
      gap: 0.55rem;
      background: #101010;
      border: 1px solid #333;
      padding: 0.75rem;
    }

    .workspace-sidebar button {
      width: 100%;
      min-width: 0;
      text-align: left;
      padding: 0.65rem 0.75rem;
    }

    .workspace-panel {
      min-width: 0;
    }

    .workspace-panel h3 {
      margin-top: 0;
      color: var(--teal);
    }

    .mini-terminal {
      margin-top: 1rem;
      padding: 0.9rem;
      background: #000;
      border: 1px solid #222;
      color: var(--green);
      white-space: pre-wrap;
      overflow-wrap: break-word;
    }

    #accessTooltip {
      display: none;
      position: fixed;
      z-index: 1000;
      max-width: min(320px, calc(100vw - 2rem));
      padding: 0.65rem 0.8rem;
      background: #e7e7e7;
      border: 1px solid #b8b8b8;
      color: #b00000;
      font-family: monospace;
      font-weight: bold;
      line-height: 1.35;
      pointer-events: none;
      box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
    }

    .contact-loading {
      cursor: wait;
      filter: grayscale(0.25) brightness(0.82);
      transform: none;
    }

    body.pre-contact-loading,
    body.pre-contact-loading * {
      cursor: wait !important;
    }

    /* Contact sequence fullscreen layers */
    #canvas, #spinner, #overlay, #freezeOverlay, #message, #finalRedBg, #finalBlueBg, #scareLayer {
      display: none;
      position: fixed;
      inset: 0;
    }

    #canvas {
      background: #000;
      z-index: 100;
      width: 100vw;
      height: 100vh;
    }

    #spinner {
      z-index: 105;
      inset: auto;
      top: 50%;
      left: 50%;
      right: auto;
      bottom: auto;
      width: clamp(48px, 10vmin, 72px);
      height: clamp(48px, 10vmin, 72px);
      border: clamp(6px, 1.4vmin, 9px) solid var(--green);
      border-top-color: transparent;
      border-radius: 50%;
      animation: spin 1s linear infinite;
      pointer-events: none;
    }

    @keyframes spin {
      from { transform: translate(-50%, -50%) rotate(0deg); }
      to { transform: translate(-50%, -50%) rotate(360deg); }
    }

    #overlay {
      z-index: 102;
      background: rgba(0,0,0,0.88);
      color: var(--green);
      padding: clamp(1rem, 4vw, 2rem);
      font-size: clamp(0.85rem, 2.4vw, 1rem);
      line-height: 1.6;
      overflow: auto;
      word-break: break-word;
    }

    #overlay .warning {
      color: #ff2222;
      font-weight: bold;
    }

    #freezeOverlay {
      z-index: 106;
      align-items: center;
      justify-content: center;
      background: rgba(218, 218, 218, 0.34);
      cursor: wait;
      padding: 1rem;
    }

    #message {
      z-index: 104;
      align-items: center;
      justify-content: center;
      text-align: center;
      white-space: pre-wrap;
      min-height: 100vh;
      min-height: 100dvh;
      padding: clamp(1rem, 5vw, 2rem);
      color: var(--teal-bright);
      background: #000;
      line-height: 1.6;
      font-size: clamp(1rem, 2.5vw, 1.35rem);
    }

    #finalRedBg {
      z-index: 103;
      background: var(--red-bg);
    }

    #finalBlueBg {
      z-index: 103;
      background: var(--blue-bg);
    }

    #scareLayer {
      z-index: 1200;
      overflow: hidden;
      background:
        radial-gradient(circle at 50% 48%, rgba(255,255,255,0.22), transparent 11rem),
        repeating-linear-gradient(0deg, rgba(255,255,255,0.08) 0 1px, transparent 1px 4px),
        #020000;
      color: #fff;
      align-items: center;
      justify-content: center;
      padding: clamp(1rem, 4vw, 3rem);
      animation: scareShake 70ms infinite steps(2), scarePulse 180ms infinite steps(2);
    }

    #scareLayer::before,
    #scareLayer::after {
      content: "";
      position: absolute;
      inset: -8%;
      pointer-events: none;
    }

    #scareLayer::before {
      background:
        linear-gradient(90deg, transparent 0 46%, rgba(255,0,0,0.7) 47% 50%, transparent 51%),
        repeating-linear-gradient(90deg, rgba(255,0,0,0.15) 0 3px, transparent 3px 13px);
      mix-blend-mode: screen;
      animation: scareTear 95ms infinite steps(3);
    }

    #scareLayer::after {
      background: radial-gradient(circle at 50% 42%, rgba(0,0,0,0) 0 9rem, rgba(255,0,0,0.42) 9.2rem 9.6rem, rgba(0,0,0,0.94) 14rem);
      animation: scareBlink 420ms infinite steps(2);
    }

    .scare-card {
      position: relative;
      z-index: 2;
      width: min(920px, 100%);
      border: 2px solid #ff1010;
      background: rgba(0, 0, 0, 0.82);
      box-shadow: 0 0 50px rgba(255, 0, 0, 0.75), inset 0 0 35px rgba(255, 0, 0, 0.35);
      padding: clamp(1.1rem, 5vw, 3rem);
      text-align: center;
      transform: scale(1.04);
      animation: scareCardJump 900ms infinite steps(2);
    }

    .scare-card h2 {
      margin: 0;
      color: #ff1010;
      font-size: clamp(2.3rem, 10vw, 7rem);
      line-height: 0.9;
      text-shadow: 4px 0 #00fff2, -4px 0 #ff00aa, 0 0 22px #ff1010;
      text-transform: uppercase;
    }

    .scare-card p {
      margin: 1rem auto 0;
      max-width: 760px;
      color: #f5f5f5;
      font-size: clamp(0.95rem, 2.4vw, 1.25rem);
      line-height: 1.45;
    }

    .scare-lines {
      margin: 1.2rem auto 0;
      display: grid;
      gap: 0.35rem;
      max-width: 680px;
      color: #00ff00;
      text-align: left;
      font-size: clamp(0.75rem, 2vw, 1rem);
    }

    .scare-terminal {
      margin-top: 1.4rem;
      color: #ff1010;
      font-weight: bold;
      letter-spacing: 0.08em;
    }

    #scareLayer.entity-mode {
      background:
        radial-gradient(circle at 50% 52%, rgba(0, 255, 120, 0.1), transparent 14rem),
        repeating-linear-gradient(0deg, rgba(0,255,120,0.08) 0 1px, transparent 1px 5px),
        #010805;
      color: #b9ffd3;
      animation: none;
    }

    #scareLayer.entity-mode::before,
    #scareLayer.entity-mode::after {
      display: none;
    }

    .entity-layout {
      position: relative;
      z-index: 2;
      width: min(1180px, calc(100vw - clamp(1.25rem, 5vw, 4rem)));
      max-height: calc(100dvh - clamp(1.25rem, 5vw, 4rem));
      display: grid;
      grid-template-columns: minmax(250px, 380px) minmax(360px, 1fr);
      gap: clamp(1rem, 4vw, 3rem);
      align-items: center;
    }

    .entity-card {
      position: relative;
      width: 100%;
      border: 1px solid rgba(0, 255, 120, 0.55);
      background: rgba(0, 12, 7, 0.86);
      box-shadow: 0 0 36px rgba(0, 255, 120, 0.2), inset 0 0 22px rgba(0, 255, 120, 0.1);
      padding: clamp(1.2rem, 5vw, 3rem);
      text-align: left;
    }

    .entity-chat {
      width: 100%;
      max-height: calc(100dvh - clamp(2rem, 8vw, 6rem));
      overflow: hidden;
      display: grid;
      gap: 0.7rem;
      align-content: start;
      pointer-events: none;
    }

    .entity-bubble {
      width: fit-content;
      max-width: 100%;
      padding: 0.75rem 0.9rem;
      border: 1px solid rgba(0, 255, 120, 0.5);
      border-radius: 7px;
      background: rgba(0, 18, 10, 0.94);
      color: #caffda;
      box-shadow: 0 0 18px rgba(0, 255, 120, 0.18);
      line-height: 1.35;
      font-size: clamp(0.82rem, 2.4vw, 0.98rem);
      animation: bubbleIn 180ms ease-out both;
    }

    .entity-card h2 {
      margin: 0;
      color: #00ff78;
      font-size: clamp(1.55rem, 5vw, 3.6rem);
      line-height: 1;
      text-transform: uppercase;
      text-shadow: 0 0 18px rgba(0,255,120,0.55);
    }

    .entity-readout {
      margin-top: 1.5rem;
      display: grid;
      gap: 0.75rem;
      font-size: clamp(0.95rem, 2.4vw, 1.25rem);
    }

    .entity-distance {
      color: #ffffff;
      font-size: clamp(2.8rem, 12vw, 8rem);
      font-weight: bold;
      line-height: 0.95;
      text-shadow: 0 0 28px rgba(0,255,120,0.8);
    }

    .run-card {
      position: relative;
      z-index: 2;
      color: #ff1010;
      text-align: center;
      font-size: clamp(3.5rem, 17vw, 12rem);
      font-weight: bold;
      line-height: 0.86;
      text-shadow: 5px 0 #00fff2, -5px 0 #ff00aa, 0 0 36px #ff1010;
      animation: scareCardJump 130ms infinite steps(2);
    }

    #scareLayer.too-late-mode {
      background:
        repeating-linear-gradient(0deg, rgba(255,255,255,0.1) 0 1px, transparent 1px 4px),
        #120000;
      animation: scareShake 55ms infinite steps(2), scarePulse 120ms infinite steps(2);
    }

    #scareLayer.too-late-mode::before,
    #scareLayer.too-late-mode::after {
      display: block;
    }

    .too-late-card {
      position: relative;
      z-index: 2;
      color: #ff1010;
      text-align: center;
      font-size: clamp(2.8rem, 13vw, 10rem);
      font-weight: bold;
      line-height: 0.9;
      text-transform: uppercase;
      text-shadow: 5px 0 #00fff2, -5px 0 #ff00aa, 0 0 36px #ff1010;
      animation: scareCardJump 110ms infinite steps(2);
    }

    @keyframes bubbleIn {
      from { opacity: 0; transform: translateX(-18px); }
      to { opacity: 1; transform: translateX(0); }
    }

    @keyframes scareShake {
      0% { transform: translate(0, 0); }
      25% { transform: translate(9px, -7px); }
      50% { transform: translate(-8px, 6px); }
      75% { transform: translate(5px, 9px); }
      100% { transform: translate(-4px, -5px); }
    }

    @keyframes scarePulse {
      0%, 45% { filter: contrast(1.35) brightness(1); }
      46%, 55% { filter: contrast(3) brightness(3.8) saturate(0); }
      56%, 100% { filter: contrast(1.8) brightness(0.85); }
    }

    @keyframes scareTear {
      0% { transform: translateX(-12%) skewX(-8deg); opacity: 0.35; }
      50% { transform: translateX(9%) skewX(11deg); opacity: 0.75; }
      100% { transform: translateX(-3%) skewX(-4deg); opacity: 0.45; }
    }

    @keyframes scareBlink {
      0%, 55% { opacity: 0.15; }
      56%, 100% { opacity: 0.9; }
    }

    @keyframes scareCardJump {
      0%, 70% { transform: scale(1.02) rotate(-0.3deg); }
      71%, 100% { transform: scale(1.1) rotate(0.6deg); }
    }

    .final-glitch-container {
      position: relative;
      display: inline-block;
      max-width: calc(100vw - clamp(2rem, 10vw, 5rem));
      font-size: clamp(1.65rem, 8vw, 4.8rem);
      font-weight: bold;
      line-height: 1.1;
      font-family: monospace;
      text-align: center;
      white-space: normal;
      overflow-wrap: break-word;
    }

    .final-static {
      color: transparent;
      display: block;
      position: relative;
      z-index: 3;
      opacity: 0;
    }

    .final-glitch-layer {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      pointer-events: none;
      opacity: 0;
      z-index: 2;
      animation: boostedGlitch 0.36s infinite linear alternate;
    }

    .final-blue-copy {
      color: var(--glitch-blue);
      text-shadow: 0 0 8px rgba(0, 204, 255, 0.9);
    }

    .final-red-copy {
      color: var(--glitch-red);
      text-shadow: 0 0 8px rgba(255, 51, 51, 0.9);
    }

    .show-blue-copy .final-blue-copy { opacity: 0.96; }
    .show-red-copy .final-red-copy { opacity: 0.96; }

    @keyframes boostedGlitch {
      0%   { transform: translate(-3px, 2px); clip-path: inset(0% 0% 70% 0%); }
      10%  { transform: translate(3px, -1px); clip-path: inset(35% 0% 35% 0%); }
      20%  { transform: translate(-4px, 3px); clip-path: inset(12% 0% 62% 0%); }
      30%  { transform: translate(4px, -2px); clip-path: inset(58% 0% 16% 0%); }
      40%  { transform: translate(-2px, 4px); clip-path: inset(42% 0% 26% 0%); }
      50%  { transform: translate(2px, -3px); clip-path: inset(4% 0% 76% 0%); }
      60%  { transform: translate(-5px, 1px); clip-path: inset(70% 0% 4% 0%); }
      70%  { transform: translate(5px, -1px); clip-path: inset(18% 0% 44% 0%); }
      80%  { transform: translate(-3px, 3px); clip-path: inset(48% 0% 22% 0%); }
      90%  { transform: translate(3px, -2px); clip-path: inset(22% 0% 52% 0%); }
      100% { transform: translate(0px, 0px); clip-path: inset(0% 0% 0% 0%); }
    }

    @media (max-width: 720px) {
      .site-shell, .simple-page {
        width: 100%;
        padding: 0;
      }

      .content-block {
        padding: 1.5rem 1rem 0;
      }

      .simple-card {
        border-left: 0;
        border-right: 0;
      }

      .detail-grid {
        grid-template-columns: 1fr;
      }

      footer { margin-top: 1.5rem; }
      .cta { gap: 0.75rem; }

      button {
        width: min(100%, 210px);
      }

      .top-login {
        width: auto;
      }

      #scareLayer.entity-mode {
        align-items: stretch;
        justify-content: flex-start;
        padding: 0.75rem;
        overflow: hidden;
      }

      .entity-layout {
        width: 100%;
        height: calc(100dvh - 1.5rem);
        max-height: calc(100dvh - 1.5rem);
        grid-template-columns: 1fr;
        grid-template-rows: clamp(8.5rem, 32dvh, 13rem) minmax(0, 1fr);
        gap: 0.85rem;
        align-items: stretch;
      }

      .entity-chat {
        height: 100%;
        max-height: none;
        overflow-y: auto;
        gap: 0.45rem;
        padding-right: 0.2rem;
      }

      .entity-bubble {
        padding: 0.58rem 0.68rem;
        font-size: clamp(0.72rem, 3.2vw, 0.88rem);
      }

      .entity-card {
        align-self: center;
        padding: 1rem;
        min-height: 0;
      }

      .entity-card h2 {
        font-size: clamp(1.35rem, 7.5vw, 2.2rem);
      }

      .entity-readout {
        gap: 0.45rem;
        font-size: clamp(0.78rem, 3.6vw, 1rem);
      }

      .entity-distance {
        font-size: clamp(3rem, 20vw, 5.5rem);
      }

      .subscribe-form {
        align-items: stretch;
      }

      .subscribe-form input,
      .subscribe-form button {
        width: 100%;
      }

      .subscribe-spinner {
        align-self: center;
      }

      .login-actions {
        flex-direction: row;
      }

      .login-actions button {
        width: auto;
        flex: 1 1 0;
        min-width: 0;
      }

      .dashboard-nav,
      .dashboard-grid,
      .dashboard-actions,
      .status-row,
      .workspace-shell {
        grid-template-columns: 1fr;
      }
    }
