/* ============================================================================
   HUANG//BUILDS — ANTI-AI-SLOP BIZARRE HARDWARE STYLESHEET (DESKTOP + MOBILE)
   ============================================================================ */

:root {
  --bg: #08080a;
  --panel: #111114;
  --panel-alt: #18181d;
  --ink: #ece9e2;
  --muted: #8b8982;
  --lime: #c6ff00;
  --orange: #ff4d00;
  --cyan: #00f0ff;
  --danger: #ff1e42;
  --border: #2f2f37;
  --border-hard: #ece9e2;
  --mono: "SFMono-Regular", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, Consolas, monospace;
  --display: "Arial Black", "Impact", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  cursor: crosshair;
  transition: filter 300ms ease;
}

body {
  display: flex;
  flex-direction: column;
}

/* Raw 1-bit blueprint grid background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(236, 233, 226, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(236, 233, 226, 0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  z-index: 0;
}

/* Optional CRT Scanlines */
body.crt-on::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9990;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.22) 0px,
    rgba(0, 0, 0, 0.22) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: multiply;
}

#chaos-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  pointer-events: none;
  z-index: 5;
}

/* UNHINGED LEVELS */
body.unhinged-2 .brand-mark {
  box-shadow: -3px 0 0 var(--cyan), 3px 0 0 var(--danger);
}

body.unhinged-3 {
  animation: feverHue 14s linear infinite;
}

body.unhinged-3 .stage {
  transform: skewX(-0.9deg);
}

@keyframes feverHue {
  0% { filter: hue-rotate(0deg) contrast(1.08); }
  50% { filter: hue-rotate(155deg) contrast(1.18); }
  100% { filter: hue-rotate(360deg) contrast(1.08); }
}

/* CRT DEGAUSS MAGNETIC WARP */
body.is-degaussing {
  animation: degaussWarp 760ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes degaussWarp {
  0% { transform: scale(1) skewX(0deg); filter: hue-rotate(0deg) saturate(1); }
  18% { transform: scale(1.05, 0.92) skewX(8deg); filter: hue-rotate(120deg) saturate(4) contrast(1.8); }
  38% { transform: scale(0.95, 1.04) skewX(-6deg); filter: hue-rotate(-110deg) saturate(3.2) contrast(1.5); }
  62% { transform: scale(1.02, 0.98) skewX(3deg); filter: hue-rotate(45deg) saturate(2); }
  100% { transform: scale(1) skewX(0deg); filter: hue-rotate(0deg) saturate(1); }
}

/* ---------------- CURSED SYSTEM TOASTS ---------------- */
.toast-host {
  position: fixed;
  top: 64px;
  right: 12px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  max-width: calc(100vw - 24px);
}

.cursed-toast {
  background: #0b0b0e;
  border: 2px solid var(--cyan);
  color: var(--cyan);
  padding: 6px 10px;
  font-size: 11px;
  box-shadow: 4px 4px 0 #000;
  animation: toastSlide 180ms steps(4);
}

.cursed-toast.danger {
  border-color: var(--danger);
  color: var(--danger);
}

@keyframes toastSlide {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---------------- TOP HARDWARE TELEMETRY BAR ---------------- */
.topbar {
  position: relative;
  flex-shrink: 0;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 10px 6px 10px;
  background: var(--panel);
  border-bottom: 2px solid var(--border-hard);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  font-family: var(--display);
  font-size: 16px;
  letter-spacing: 0.08em;
  background: var(--lime);
  color: #09090b;
  padding: 2px 7px;
  border: 2px solid #09090b;
  box-shadow: 3px 3px 0 var(--orange);
  white-space: nowrap;
}

.brand-meta {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@media (max-width: 1320px) and (min-width: 861px) {
  .brand-meta {
    display: none;
  }
}

.brand-meta strong {
  color: var(--ink);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.hw-btn {
  appearance: none;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--panel-alt);
  color: var(--ink);
  border: 2px solid var(--border-hard);
  padding: 4px 7px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--border-hard);
  transition: transform 60ms linear, box-shadow 60ms linear;
  white-space: nowrap;
  flex-shrink: 0;
}

.hw-btn:hover {
  background: var(--lime);
  color: #09090b;
}

.hw-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--border-hard);
}

.hw-btn.danger {
  border-color: var(--orange);
  color: var(--orange);
  box-shadow: 2px 2px 0 var(--orange);
}

.hw-btn.danger:hover {
  background: var(--orange);
  color: #09090b;
}

.hw-btn.accent-cyan {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 2px 2px 0 var(--cyan);
}

.hw-btn.accent-cyan:hover {
  background: var(--cyan);
  color: #09090b;
}

.hw-btn.boring-escape {
  border-color: var(--muted);
  color: var(--muted);
  box-shadow: none;
  font-weight: 400;
  position: relative;
}

.hw-btn.boring-escape:hover {
  background: var(--ink);
  color: #09090b;
}

.slop-counter {
  font-size: 11px;
  padding: 4px 8px;
  border: 1px dashed var(--danger);
  color: var(--danger);
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.mobile-only {
  display: none;
}

/* ---------------- PHYSICS WORKBENCH STAGE ---------------- */
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  touch-action: none;
  z-index: 10;
}

.stage-watermark {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 0 16px 120px 16px;
  text-align: center;
  opacity: 0.14;
}

.stage-watermark h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(38px, 9vw, 130px);
  line-height: 0.88;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  -webkit-text-stroke: 2px var(--ink);
  color: transparent;
}

.stage-watermark p {
  margin-top: 10px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ---------------- PROJECT CARTRIDGES ---------------- */
.cartridge {
  position: absolute;
  top: 0;
  left: 0;
  width: 248px;
  min-height: 156px;
  background: rgba(17, 17, 20, 0.95);
  border: 2px solid var(--border-hard);
  box-shadow: 5px 5px 0 #000000;
  cursor: grab;
  will-change: transform;
  touch-action: none;
  z-index: 20;
}

.cartridge.is-dragging {
  cursor: grabbing;
  z-index: 80;
  box-shadow: 10px 10px 0 rgba(198, 255, 0, 0.35);
}

.cartridge.is-panicking {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger);
}

.cart-grip {
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  border-bottom: 2px solid #09090b;
  background-image: repeating-linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.25) 0px,
    rgba(0, 0, 0, 0.25) 2px,
    transparent 2px,
    transparent 6px
  );
}

.cart-led {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #09090b;
  margin-right: 5px;
  animation: ledBlink 1.1s steps(2) infinite;
}

@keyframes ledBlink {
  0% { opacity: 1; }
  100% { opacity: 0.2; }
}

.cart-body {
  padding: 10px;
}

.cart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.cart-title {
  margin: 0;
  font-family: var(--display);
  font-size: 17px;
  line-height: 1;
  letter-spacing: 0.03em;
  color: var(--ink);
}

.cart-glyph {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  padding: 3px;
  background: #050507;
}

.cart-blurb {
  margin: 0 0 6px 0;
  font-size: 11px;
  line-height: 1.32;
  color: #c5c2ba;
}

.cart-whisper {
  font-size: 9px;
  color: var(--orange);
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  min-height: 12px;
  text-transform: uppercase;
}

.cart-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  font-size: 10px;
}

.cart-url {
  color: var(--lime);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 145px;
}

.cart-boot-btn {
  appearance: none;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 6px;
  background: var(--lime);
  color: #09090b;
  border: 1px solid #09090b;
  cursor: pointer;
  flex-shrink: 0;
}

.cart-boot-btn:active {
  background: var(--ink);
}

/* ---------------- INVADING AI SLOP CARD (MOCKERY!) ---------------- */
.slop-card {
  position: absolute;
  top: 0;
  left: 0;
  width: 248px;
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 52%, #ec4899 100%);
  color: #ffffff;
  font-family: system-ui, -apple-system, sans-serif;
  box-shadow: 0 14px 36px rgba(168, 85, 247, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.35);
  cursor: grab;
  will-change: transform;
  touch-action: none;
  z-index: 25;
}

.slop-card.is-dragging {
  cursor: grabbing;
  z-index: 85;
}

.slop-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  margin-bottom: 6px;
}

.slop-card h3 {
  margin: 0 0 4px 0;
  font-size: 15px;
  line-height: 1.2;
}

.slop-card p {
  margin: 0 0 10px 0;
  font-size: 11px;
  opacity: 0.9;
}

.slop-cta {
  display: inline-block;
  background: #ffffff;
  color: #4f46e5;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
}

.slop-hint {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  color: #fef08a;
  letter-spacing: 0.05em;
}

/* ---------------- MITOSIS COOKIE GREMLIN ---------------- */
.cookie-gremlin {
  position: absolute;
  top: 0;
  left: 0;
  width: 226px;
  padding: 10px;
  background: #ffe600;
  color: #09090b;
  border: 2px solid #09090b;
  box-shadow: 5px 5px 0 var(--danger);
  cursor: grab;
  will-change: transform;
  touch-action: none;
  z-index: 26;
}

.cookie-gremlin h4 {
  margin: 0 0 4px 0;
  font-family: var(--display);
  font-size: 13px;
}

.cookie-gremlin p {
  margin: 0 0 8px 0;
  font-size: 10px;
  line-height: 1.3;
}

.cookie-actions {
  display: flex;
  gap: 6px;
}

.cookie-btn {
  flex: 1;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  padding: 6px 6px;
  border: 2px solid #09090b;
  background: #09090b;
  color: #ffe600;
  cursor: pointer;
}

.cookie-btn.decline {
  background: #ffffff;
  color: #09090b;
}

/* ---------------- BOTTOM HARDWARE DOCK ---------------- */
.dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(112px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 40;
  display: grid;
  grid-template-columns: 1fr 290px 220px;
  background: var(--panel);
  border-top: 2px solid var(--border-hard);
}

.shell-box {
  display: flex;
  flex-direction: column;
  border-right: 2px solid var(--border-hard);
  padding: 6px 10px;
  overflow: hidden;
  height: 100%;
}

.shell-log {
  flex: 1;
  overflow-y: auto;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
  margin-bottom: 6px;
}

.shell-log .ok { color: var(--lime); }
.shell-log .err { color: var(--danger); }

.shell-form {
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 5px;
}

.shell-prompt {
  color: var(--lime);
  font-weight: 700;
}

.shell-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  user-select: text;
  -webkit-user-select: text;
}

.boot-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-right: 2px solid var(--border-hard);
  padding: 8px 12px;
  background: #060608;
  transition: background 100ms linear;
}

.boot-slot.is-hot {
  background: #1a2400;
  outline: 3px solid var(--lime);
  outline-offset: -5px;
}

.slot-slit {
  width: 86%;
  height: 14px;
  background: #000;
  border: 2px solid var(--lime);
  box-shadow: inset 0 4px 0 #1b2600;
  margin-bottom: 6px;
}

.slot-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--lime);
  text-transform: uppercase;
  text-align: center;
}

.slot-sub {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
  text-align: center;
}

.incinerator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  background: repeating-linear-gradient(
    -45deg,
    #1a0909 0px,
    #1a0909 10px,
    #2a0c0c 10px,
    #2a0c0c 20px
  );
  text-align: center;
  transition: background 100ms linear;
}

.incinerator.is-hot {
  background: var(--danger);
  color: #09090b;
}

.incinerator-title {
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: 0.06em;
  color: var(--orange);
}

.incinerator.is-hot .incinerator-title,
.incinerator.is-hot .incinerator-sub {
  color: #09090b;
}

.incinerator-sub {
  font-size: 10px;
  color: var(--ink);
  margin-top: 3px;
}

.spark {
  position: fixed;
  width: 7px;
  height: 7px;
  pointer-events: none;
  z-index: 9995;
}

/* ---------------- BOOT WARP OVERLAY ---------------- */
.warp-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: #050507;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px;
  text-align: center;
}

.warp-overlay.active {
  display: flex;
}

.warp-box {
  max-width: 540px;
  width: 100%;
  border: 2px solid var(--lime);
  padding: 18px;
  background: #0b0b0e;
  box-shadow: 8px 8px 0 var(--lime);
}

.warp-title {
  font-family: var(--display);
  font-size: clamp(20px, 5vw, 26px);
  color: var(--lime);
  margin: 0 0 8px 0;
}

.warp-url {
  font-size: 12px;
  color: var(--cyan);
  word-break: break-all;
  margin-bottom: 10px;
}

.warp-post {
  font-size: 11px;
  color: var(--orange);
  min-height: 16px;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.warp-bar-wrap {
  width: 100%;
  height: 16px;
  border: 2px solid var(--ink);
  margin-bottom: 14px;
}

.warp-bar {
  height: 100%;
  width: 0%;
  background: var(--lime);
  transition: width 80ms linear;
}

.warp-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------------- DEADPAN BORING MODE ---------------- */
body.boring-mode {
  display: block;
  overflow: auto;
  height: auto;
  min-height: 100vh;
  background: #ffffff;
  color: #000000;
  font-family: "Times New Roman", Times, serif;
  cursor: auto;
  animation: none !important;
  filter: none !important;
}

body.boring-mode::before,
body.boring-mode::after,
body.boring-mode #chaos-canvas,
body.boring-mode #toast-host,
body.boring-mode .topbar,
body.boring-mode .stage {
  display: none !important;
}

.boring-view {
  display: none;
  max-width: 760px;
  margin: 24px auto;
  padding: 0 16px;
}

body.boring-mode .boring-view {
  display: block;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.boring-view table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.boring-view th,
.boring-view td {
  border: 1px solid #000;
  padding: 8px 10px;
  text-align: left;
  font-size: 14px;
}

.boring-view a {
  color: #0000ee;
  word-break: break-all;
}

/* ---------------- MOBILE & TABLET RESPONSIVE ---------------- */
@media (max-width: 860px) {
  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: inline-flex;
    align-items: center;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: calc(6px + env(safe-area-inset-top, 0px)) 8px 6px 8px;
  }

  .brand-block {
    justify-content: space-between;
    gap: 8px;
  }

  .brand-mark {
    font-size: 15px;
    padding: 2px 6px;
  }

  .brand-meta {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Horizontal swipeable hardware switch rail */
  .controls {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .controls::-webkit-scrollbar {
    display: none;
  }

  .hw-btn {
    padding: 7px 10px;
    font-size: 11px;
  }

  /* Compact touch-sized cartridges & hostile cards */
  .cartridge {
    width: 178px;
    min-height: 118px;
  }

  .cart-body {
    padding: 7px;
  }

  .cart-title {
    font-size: 14px;
  }

  .cart-glyph {
    width: 22px;
    height: 22px;
  }

  .cart-blurb {
    font-size: 10px;
    line-height: 1.25;
    margin-bottom: 4px;
  }

  .cart-whisper {
    font-size: 8px;
    margin-bottom: 4px;
  }

  .cart-url {
    max-width: 96px;
    font-size: 9px;
  }

  .slop-card {
    width: 184px;
    padding: 10px;
  }

  .slop-card h3 {
    font-size: 13px;
  }

  .slop-card p {
    font-size: 10px;
    margin-bottom: 6px;
  }

  .cookie-gremlin {
    width: 178px;
    padding: 8px;
  }

  .dock {
    grid-template-columns: 1fr 1fr;
    min-height: 90px;
  }

  /* Mobile BIOS drawer pops up above the dock when toggled */
  .shell-box {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 150px;
    max-height: 150px;
    background: rgba(12, 12, 16, 0.98);
    border-right: none;
    border-top: 2px solid var(--lime);
    z-index: 60;
  }

  .shell-box.is-open {
    display: flex;
  }

  .slot-label,
  .incinerator-title {
    font-size: 11px;
  }

  .slot-sub,
  .incinerator-sub {
    font-size: 9px;
  }

  .toast-host {
    top: 86px;
    right: 8px;
  }
}
